剪刀石头布c语言 循环程序,什么方法最简单编剪刀石头布程序

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

水平有限,凑合吧...

#include 

#include 

#include 

int main()

{

printf("初始分数为0分。赢了加一分,输了减一分,到达6分胜利。到达-6分失败。\n");

int score=0;

do

{

if(score==6)

{

int x=0;

for(x=0;x<10;x++)

printf("YoU WrE tHe WiNnEr!! CoNgRaTuLaTiOnS!!!\n");

fflush(stdin);

getchar();

return 0;

}

if(score==-6)

{

int x=0;

for(x=0;x<10;x++)

printf("YoU lOsT! LoSeR, SuCkEr.\n");

fflush(stdin);

getchar();

return 0;

}

int in;

srand((unsigned)time(NULL));

in=rand()%3;

printf("请选择: 1为剪刀,2为石头,3为布\n");

int choice;

scanf("%d",&choice);

switch(in)

{

case 0:

printf("电脑的选择是剪刀。\n");

if(choice==1)

{

printf("平手,请继续。\n");

}

if(choice==2)

{

printf("你赢了,请继续。\n");

score++;

}

if(choice==3)

{

printf("你输了,请继续。\n");

score--;

}

printf("你现在的分数为:%d.\n",score);

break;

case 1:

printf("电脑的选择是石头。\n");

if(choice==1)

{

printf("你输了,请继续。\n");

score--;

}

if(choice==2)

{

printf("平手,请继续。\n");

}

if(choice==3)

{

printf("你赢了,请继续。\n");

score++;

}

printf("你现在的分数为:%d.\n",score);

break;

case 2:

printf("电脑的选择是布。\n");

if(choice==1)

{

printf("你赢了,请继续。\n");

score++;

}

if(choice==2)

{

printf("你输了,请继续。\n");

score--;

}

if(choice==3)

{

printf("平手,请继续。\n");

}

printf("你现在的分数为:%d.\n",score);

break;

default:

printf("something's wrong.maybe you entered some number other than 1,2,or 3.\n");

}

}while(1);

return 0;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值