📄 caishuzi.c
字号:
/*下面是一个猜数字的游戏,游戏的规则很简单:任意输入一个数之后,系统将提示你猜的数是大了,
还是小了,五次还未猜出则本轮结束。宁可以继续玩!!但本程序有点问题请大家指正!!*/
#include "time.h"
#include "stdio.h"
#include "stdlib.h"
main()
{char c; clock_t start,end;
time_t a,b;
double var; int i,guess;
srand(time(NULL));
printf("do you wnat to play it.('y'or 'n')\n");
loop:
while((c=getch())=='y')
{i=rand()%100;
printf("\n please input number you guess:\n");
start=clock();
a=time(NULL);
scanf("%d",&guess);
while (guess!=i)
{if (guess>i)
{printf("please input a little smaller.\n");
scanf("%d",&guess);}
else
{printf(" plese input a little bigger .\n");
scanf("%d",&guess);}
}end=clock();
b=time(NULL);
printf("\1: It take you %6.3f seconds\n",var=(double)(end-start)/1.82);
printf("\1: It took you %6.3f seconds\n",difftime(b,a));
if (var<15)
printf("\1\1 You are very clever!\1\1\n"); else if (var>25)
printf("\1\1 you are normal!\1\1\n\n");
else
printf("\1\1 you are stupid!\1\1\n\n");
printf("\1\1 congralations \1\1\n\n");
printf("The number you guess is %d",i);
}
printf ("\n do you want to try it again ? (\"y\",or \"n\")\n");
if ((c=getch())=='y')
goto loop;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -