vc6.0使用过程的的问题~~
代码如下:
#include"stdio.h"
#include"stdlib.h"
#include"time.h"
#include"conio.h"
int main(void)
{
int answer;
char if_continue=' ';//条件控制变量
int input=-1;//猜的数字
int num;//该变量记录你开始猜到猜对画的次数
printf("********************************\n");
printf("**本程序实现0~100的猜数字游戏**\n");
printf("********************************\n");
//我们选用当前时间作为产生均匀随机数的种子,
//使得每次产生的随机数序列都不一样
srand((unsigned)time(NULL));
while(if_continue==' ')
{
//产生一个0~100的随机整数数
answer=(int)((float)rand()/float(RAND_MAX)*100.0);
printf("程序已经产生一个数字!\n\n");
num=0;//新开始一次游戏,所花猜测次数都需要清零
do//判断你的猜测是否正确
{
printf("请输入你猜的数字0~100\n");
scanf("%d",&input);
if(input<answer)
{
printf("很遗憾你猜小了!!\n");
num++;
continue;
}
if(input>answer)
{
printf("很遗憾你猜大了!!\n");
num++;
continue;
}
printf("$$$恭喜你猜对了!答案是:%d\n",input);
num++;
}while(input!=answer);
printf("你总共用了%d次猜对了数字!\n\n",num);
printf("还想继续猜数字吗?(继续请按空白键SPACE)\n");
if_continue=getch();
}
return 1 ;
}
编译成功 连接成功 但是运行的结果却是:
" *******************************
**本程序实现0~100的猜数字游戏**
press anykey to continue"
我换了些其它的代码上去编译~~发现只能运行顺序语句~~
换了其它的编程工具也出现了同样的问题 连重装系统都不能解决
本人编程菜聊 还请吧里大神帮忙解决 ~~不胜感激!!
[解决办法]
#include <stdio.h>#include <stdlib.h>#include <time.h>#include <conio.h>int main(void){ int answer; char if_continue = ' '; //条件控制变量 int input = -1; //猜的数字 int num; //该变量记录你开始猜到猜对画的次数 printf("********************************\n"); printf("**本程序实现0~100的猜数字游戏**\n"); printf("********************************\n"); //我们选用当前时间作为产生均匀随机数的种子, //使得每次产生的随机数序列都不一样 srand((unsigned)time(NULL)); while (if_continue == ' ') { //产生一个0~100的随机整数数 answer = (int)((float)rand()/float(RAND_MAX)*100.0); printf("程序已经产生一个数字!\n\n"); num = 0;//新开始一次游戏,所花猜测次数都需要清零 do //判断你的猜测是否正确 { printf("请输入你猜的数字0~100\n"); scanf("%d", &input); if (input < answer) { printf("很遗憾你猜小了!!\n"); num++; continue; } if (input > answer) { printf("很遗憾你猜大了!!\n"); num++; continue; } printf("$$$恭喜你猜对了!答案是:%d\n", input); num++; } while (input != answer); printf("你总共用了%d次猜对了数字!\n\n", num); printf("还想继续猜数字吗?(继续请按空白键SPACE)\n"); if_continue = getch(); } return 1;}