国内外C语言游戏设计现状和趋势
发布网友
发布时间:2022-04-25 11:19
我来回答
共1个回答
热心网友
时间:2024-03-26 18:10
includestdio.h;
includestdlib.h;
int main()
{
char cq[][10]={;石头;,;剪刀;,;布;};
int guess=-1,r,youwin=0,mewin=0,daping=0,total=0;
srand(time(NULL));
while(1)
{
r=(int)((rand()/(RAND_MAX+1.0))*3);
printf(;0、石头;n1、剪刀;n2、布;n3、退出;n我已出,请你出:;);
scanf(;%d;,guess);
if(3==guess)
{
break;
}
else
{
total++;
printf(;这一次你出的是%s,我出的是%s,所以;,cq[guess],cq[r]);
if(0==guess1==r 1==guess2==r 2==guess0==r)
{
youwin++;
printf(;你赢了!;n;);
}
else if(guess==r)
{
daping++;
printf(;我们打平了!;n;);
}
else
{
mewin++;
printf(;我赢了!;n;);
}
}
}
printf(;总共玩了%d次,你赢了%d次,我赢了%d次,打平%d次!;n;,total,youwin,mewin,daping);
system(;PAUSE;);
return EXIT_SUCCESS;
}