目录
- 开头
- 程序
- 程序的流程图
- 程序游玩的效果
- 下一篇博客要说的东西
开头
大家好,我叫这是我58。
程序
#include <iostream>
#include <Windows.h>
using namespace std;
int main() {
	int ir = 1;
	char chparr[2] = { 0 };
	int ip1 = 0;
	int ip2 = 0;
	int i = 1;
	cout << "欢迎你们来玩这个比大小游戏,在这个游戏中,P1只能输入1~8以内的数和未知数X来跟P2的数比大小,P2也只能输入1~8以内的数和未知数X来跟P1的数比大小,这里面的未知数X的规则是:如果对面的数<5,那么未知数X=0,否则未知数X=9,而如果P1的数大于P2的数,那么P1记一分,如果P2的数大于P1的数,那么P2记一分,如果P1的数等于P2的数,那么谁都不记一分,这样的对局一共有三轮,如果P1的分大于P2的分,那么P1胜利,如果P2的分大于P1的分,那么P2胜利,但如果P1的分等于P1的分,那么P1和P2就平局了,你听明白了吗?" << endl << endl;
	for (; ir < 4; ir++) {
		system("pause");
		system("color 07");
		system("cls");
		cout << "第" << ir << "局\t" << ip1 << " : " << ip2 << endl;
		for (i = 1; i < 3; i++) {
			cout << "1 2 3 4 5 6 7 8 X" << endl << "请P" << i << "输入上面的其中一个数字 -> ";
			cin >> chparr[i - 1];
			rewind(stdin);
			while (!(chparr[i - 1] > '0' && chparr[i - 1] < '9' || 'X' == chparr[i - 1])) {
				cout << "\033[31;1m输入错误\033[0m,请P" << i << "重新输入上面的其中一个数字 -> ";
				cin >> chparr[i - 1];
				rewind(stdin);
			}
			chparr[i - 1] -= '0';
			cout << endl;
		}
		cout << endl;
		for (i = 0; i < 2 && chparr[0] != chparr[1]; i++) {
			40 == chparr[i] && (chparr[1 - i] < 5 && (chparr[i] = 0), chparr[1 - i] < 5 || (chparr[i] = 9));
		}
		if (chparr[0] > chparr[1]) {
			system("color 02");
			cout << "P1胜,记一分" << endl;
			ip1++;
		}
		else if (chparr[0] < chparr[1]) {
			system("color 02");
			cout << "P2胜,记一分" << endl;
			ip2++;
		}
		else {
			system("color 08");
			cout << "平局,无人记分" << endl;
		}
	}
	system("pause");
	system("color 07");
	system("cls");
	cout << ip1 << " : " << ip2 << endl << "最终获胜的人是:";
	Sleep(1500);
	if (ip1 > ip2) {
		system("color 0A");
		cout << "P1!" << endl;
	}
	else if (ip1 < ip2) {
		system("color 0A");
		cout << "P2!" << endl;
	}
	else {
		system("color 08");
		cout << "无人,请再接再厉!" << endl;
	}
	return 0;
}
程序的流程图
程序游玩的效果
比大小游戏
下一篇博客要说的东西
C++3D迷宫





![nginx: [emerg] unknown “connection_upgrade“ variable 解决与思考](https://i-blog.csdnimg.cn/direct/7d411d1ba0874e81a3d65863fcfc6a8b.png)







![[产品管理-21]:NPDP新产品开发 - 19 - 产品设计与开发工具 - 详细设计与规格定义](https://i-blog.csdnimg.cn/direct/0da93f21dd5c4d45b571ca975a5647bb.png)






