我这个c语言程序流程走向是什么?

来源:百度知道 编辑:UC知道 时间:2024/09/20 20:26:56
#include "time.h"
#include "stdlib.h"
#include "stdio.h"
main()
{
char c;
clock_t start,end;
time_t a,b;
double var;
int i,guess;
srand(time(NULL));
printf("do you want to play it.('y' or 'n') \n");
loop:
while((c=getchar())=='y')
{
i=rand()%100;
printf("\nplease 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("please input a little bigger.\n");
scanf("%d",&guess);
}
}
end=clock();
b=time(NULL);
printf("\1: It took you %6.3f seconds\n",var=(double)(end-start)/18.2);
printf

我没有仔细看你的程序,这种猜字游戏很简单的。
就是要求用户输入一个数字,然后给自身产生的随机数进行比较,提示用户是猜大了还是猜小了,并统计用户到猜对为止总共猜的次数.