100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > c语言模拟石头 剪子布游戏 用C++如何做出石头剪刀布的游戏。。。初学者不给力啊...

c语言模拟石头 剪子布游戏 用C++如何做出石头剪刀布的游戏。。。初学者不给力啊...

时间:2023-02-28 01:12:07

相关推荐

c语言模拟石头 剪子布游戏 用C++如何做出石头剪刀布的游戏。。。初学者不给力啊...

该楼层疑似违规已被系统折叠隐藏此楼查看此楼

#include

#include

using namespace std;

int main()

{

int s;

srand(int(0));

int win = 0, lose = 0,draw = 0;

while (cout << "出招吧! 1 = 剪刀, 2 = 石头, 3 = 布: ", cin >> s)

{

int c = (rand() % 3) + 1;

if (s > c &&s!=0 && s<=3)

{

cout << "他出 " << c << ", 你出 " << s << endl;

cout << "你赢了!" << endl;

win++;

cout << endl;

}

else if (s != c && s != 0 && s <= 3)

{

switch (c)

{

case 1: cout << "他出 " << c << ", 你出 " << s << endl;

cout << "你输了!" << endl << endl;

lose++; break;

case 2: cout << "他出 " << c << ", 你出 " << s << endl;

cout << "你输了!" << endl << endl;

lose++; break;

case 3: cout << "他出 " << c << ", 你出 " << s << endl;

cout << "你输了!" << endl << endl;

lose++; break;

default: cout << "你是否超越了数字 1~3 的范围?" << endl;

}

}

else if (s == c)

{

cout << "他出 " << c << ", 你出 " << s << endl;

cout << "是和局!" << endl;

draw++;

cout << endl;

}

else

cout << "你是否超越了数字 1~3 的范围?" << endl << endl;

}

cout << "你总共赢了:" << win << ", 输了:" << lose <

system("pause");

return 0;

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。