⑴ C語言 怎麼用C語言設計一個猜拳游戲 剪刀石頭布用1.2.3代替 要玩5局3勝,
#include <stdio.h>
#include <time.h>
int main()
{
int a,b,i,m=0,n=0;
srand(time(NULL));
for(i=0;i<10;i++)
{
a=rand()%3+1;
printf("%d",a);
b=rand()%3+1;
printf("%d\n",b);
if(a>b) m++;
else if(a<b) n++;
if(m>3)
{
printf("a is the winner");
break;
}
if(n>3)
{
printf("b is the winner");
break;
}
}
return 0;
}