猜字游戏c语言程序,C语言 猜字游戏
#include
#include
#include
#include
main()
{
char c;
clock_t start, end;
time_t a, b;
double var;
int i, guess;
int YY;
srand(time(NULL));
printf("do you want to play it.('y' or 'n') \n");
loop:
while((c=getchar()) == 'y')
{
i = rand()%100;
YY = 1;
printf("\nPlease input number you guess:\n");
start = clock();
a = time(NULL);
scanf("%d", &guess);
while(guess!=i)
{
printf("%d %c\n", guess, guess);
if(guess>i)
{
printf("please input a little smaller.\n");
if(!scanf("%d", &guess)){YY = 0;
break;
};
}
else
{
printf("please input a little bigger.\n");
if(!scanf("%d", &guess)){YY = 0;
break;
};
}
}
end = clock();
b = time(NULL);
printf("\1: It took you %6.3f seconds\n", var=(double)(end-start)/1000);
printf("\1: It took you %6.3f seconds\n\n", difftime(b, a));
if(YY == 0)
{
printf("input data type error!");
}
else if(var < 15 && YY == 1)
{
printf("\1\1 You are vary clever! \1\1\n\n");
}
else if(var < 25 && YY == 1)
{
printf("\1\1 you are normal! \1\1\n\n");
}
else
{
printf("\1\1 you are stupid!\1\1\n\n");
}
if(YY == 1)
{
printf("The number you guess is %d", i);
}
}
printf("\nDo you want to try t again?(\"y\".or.\"n\")\n");
if((c=getch()) == 'y')
goto loop;
}
【猜字游戏c语言程序,C语言 猜字游戏】//对数据进行简单的异常处理
推荐阅读
- c语言|c语言 猜字游戏,【c语言】 小游戏――猜字游戏
- 笔记|C语言的猜字游戏
- c语言猜字游戏中期报告,c语言小程序(编写猜字游戏)
- 投稿|米哈游网易上线iOS云游戏后,云游行业三股势力洗牌了
- 成为上周英国数字版游戏销量榜榜首
- JavaScript实现气球打字游戏
- win7系统设置虚拟内存 玩游戏中关村Win7出错虚拟内存太小怎样办
- win7系统游戏不兼容 DNF游戏与雨林木风Win7系统不兼容的处理办法
- 游戏|中国游戏出海的“中场战事”
- 玩LOL游戏在XP电脑中安全证书不可用的处理办法