跪求C语言的注释 急急急!!!
答案:1 悬赏:70 手机版
解决时间 2021-03-27 05:48
- 提问者网友:欲望失宠
- 2021-03-26 14:26
跪求C语言的注释 急急急!!!
最佳答案
- 五星知识达人网友:蕴藏春秋
- 2021-03-26 15:04
#include "time.h"
#include "stdlib.h"
#include "stdio.h"
main()
{
//由于快2年没搞C了。所以有的地方可能有误,是凭记忆注释的。
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'){ //获取字符,为y继续循环
i=rand()%100; //随机数取模
printf("\nplease input number you guess:\n");
start=clock(); //记数器开始,单位是1/1000秒
a=time(NULL); //设置为当前时间
scanf("%d",&guess); //输入guess
while(guess!=i){ //如果不等于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("\1: it took you %6.3f seconds\n\n",difftime(b,a));
if(var<15)
printf("\1\1 You are very clever! \1\1\n\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 Congradulations \1\1\n\n");
printf("The number you guess is %d",i);
}
printf("\ndo you want to try it again?(\"yy\".or.\"n\")\n");
if((c=getchar())=='y') //如果想再玩一次返回Loop:
goto loop;
#include "stdlib.h"
#include "stdio.h"
main()
{
//由于快2年没搞C了。所以有的地方可能有误,是凭记忆注释的。
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'){ //获取字符,为y继续循环
i=rand()%100; //随机数取模
printf("\nplease input number you guess:\n");
start=clock(); //记数器开始,单位是1/1000秒
a=time(NULL); //设置为当前时间
scanf("%d",&guess); //输入guess
while(guess!=i){ //如果不等于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("\1: it took you %6.3f seconds\n\n",difftime(b,a));
if(var<15)
printf("\1\1 You are very clever! \1\1\n\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 Congradulations \1\1\n\n");
printf("The number you guess is %d",i);
}
printf("\ndo you want to try it again?(\"yy\".or.\"n\")\n");
if((c=getchar())=='y') //如果想再玩一次返回Loop:
goto loop;
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯