永发信息网

帮我看一下这个C语言哪里错啦~谢谢!

答案:2  悬赏:0  手机版
解决时间 2021-03-10 07:32
  • 提问者网友:一抹荒凉废墟
  • 2021-03-09 11:45
#include
#include
#include
#include
int main(void)
{
int guess =0;
int chosen=0;
double limit =0.0L;
bool faithtest = false;
int chance =0;

printf("\nThis is a guessing game,and now you need to enter a Positive Integer number as the upper limit for generating random numbers, the minimum of 1");
// now faith test//
for( ;!faithtest;)
{
scanf("%f",&limit);
if((int)limit == limit)
faithtest == true;
else
printf("\nA Positive Integer is needed!Please try again!");
}

// the main achitecture of the game //

srand(time(NULL));
chosen = 1 + rand()%limit;

printf("\n\nI have chosen a lucky number between 1 and %d,please find it out.",limit);
printf("\n\nNow enter the number and press 'enter' key!");
printf("\nObviously,I will count the chance you used.");

for( ; ;++chance)
{
scanf("%d",&guess);
if(guess == chosen)
break;
else
printf("\nSorry it's wrong.Now you have used %d time%s.",chance,chance ==1?"":"s");
}

printf("\nCongratulations!The number was %d.You have wasted %d time%s",chosen,chance,chance ==1?"":"s");

system("pause");
return 0;
}

编译器提示: chosen = 1 + rand()%limit; 这句导致编译失败
另外,把这句删掉以后,编译成功,但是没有窗口运行出来
编译器:啊哈C
最佳答案
  • 五星知识达人网友:琴狂剑也妄
  • 2021-03-09 13:01
你就不能加点注释么 实在是难看 chosen = 1 + rand()%limit; 类型不一致 在说了 你就不能换个专业软件 啊哈C很多都被修改了
全部回答
  • 1楼网友:末日狂欢
  • 2021-03-09 13:10
输入的地方写错了 ,应该是scanf("%d",&m1);scanf("%d",&m2); 另外调用fun()函数应该是fun(m1) fun(m2) 主函数里定义的m似乎没用?
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯