首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

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

2013-01-05 
简单的猜数字出错。求修改#include stdio.h#include stdlib.h#include ctype.hint main(){int count,

简单的猜数字出错。求修改
#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比较好    

热点排行