读书人

容易的猜数字出错。求修改

发布时间: 2013-01-05 15:20:39 作者: rapoo

简单的猜数字出错。求修改
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>



int main()
{
int count,number,guess;
char yes='Y';
printf("\nNow let us play the games:\nGuess the number");
while(toupper(yes)=='Y')
{
count=0;
randomize();
number=random(100)+1;
do{
do{
printf("\nInput an number(1_100)");
scanf("%d",&guess);
}while(guess>=1&&guess<=100);
if(number>guess)
printf("\nYour answer is low,try again");
else
printf("\nYour answer is high,try again");
count++;
if(count==15)
{
printf("\nThis is the %d times!thank it hard next!\nright number is %d",count,number);
exit(0);

}
}while(guess!=number);
if(count<=7)
{printf("\nYou have got int in %d time.\n",count);printf("Congretulations!");}
else {

printf("\nYou have got int in %d time.\n",count);

printf("\n I bet you can do it better");

}
printf("\n NEXT?(Y/N):");scanf("%c",&yes);
}
return 0;



}

[解决办法]
换srand和rand试试
[解决办法]
srand和rand函数可以参考下面的代码

怪不得学C语言时候老师不给学生用其他编译器呢!  新手还是用TC比较好    

读书人网 >C++

热点推荐