永发信息网

怎么这个抢30的C语言程序编译不过去

答案:2  悬赏:10  手机版
解决时间 2021-11-16 12:39
  • 提问者网友:皆是孤独
  • 2021-11-16 03:33
怎么这个抢30的C语言程序编译不过去
最佳答案
  • 五星知识达人网友:话散在刀尖上
  • 2021-11-16 03:42
#include
#include
#include
int input(int t);
int copu(int s);
int main() {
int tol=0;
printf("\n* * * * * * * *catch thirty* * * * * * * \n");
printf("Game Begin\n");
//randomize();
srand(0);//初始化随机发生器,srand()中的整数就是种子,一般以时间为种子!
// 即,使用这个:srand(time(NULL));
//rand()%2 是取1或2的随机数
if ( rand()%2 ==1)
tol=input(tol);
while (tol!=30)
if ((tol=copu(tol))==30)
printf("I lose! \n");
else
if ((tol=input(tol))==30)
printf("I lose! \n");
printf(" * * * * * * * *Game Over * * * * * * * *\n");
}
int input(int t) {
int a;
do {
printf("Please count:");
scanf("%d",&a);
if (a>2||a<1||t+a>30)
printf("Error input,again!");
else
printf("You count:%d\n",t+a);
} while (a>2||a<1||t+a>30);
return t+a;
}
int copu(int s) {
int c;
printf("Computer count:");
if ((s+1)%3==0)
printf(" %d\n",++s);
else if ((s+2)%3==0) {
s+=2;
printf(" %d\n",s);
} else {
c=rand()% 2 +1;
s+=c;
printf(" %d\n",s);
}
return s;
}
全部回答
  • 1楼网友:琴狂剑也妄
  • 2021-11-16 03:48
main()函数的返回值类型是int,所以应该在main()函数的结尾添加return 0;语句。

randomize();
改为
srand(time(0));

random(2)
改为
rand()%2
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯