#include<iostream>
using namespace std;
int main()
{
char a, b;
cout << "please the player A input" << endl;
cin >> a ;
cout << "please the player B input" << endl;
cin >> b;
if (a - b)
switch (a - b)
{
case 1: cout << "The winner is B" << endl; break;
case 3: cout << "The winner is A" << endl; break;
case -1:cout << "The winner is A" << endl; break;
case 2: cout << "The winner is B" << endl; break;
case -3:cout << "The winner is B" << endl; break;
case -2:cout << "The winner is A" << endl; break;
}
else
cout << "平局" << endl;
return 0;
}
编程模拟剪刀、石头和布游戏。游戏规则为:剪刀剪纸,石头砸剪刀,布包石头。玩游戏者从键盘输入s(表示剪刀)或r(表示石头)或p(表示布),要求两个游戏者交替输入,计算机给出输赢的信息。
最新推荐文章于 2024-06-18 21:48:03 发布