|
![]() | 作者: ziaichen [ziaichen]
![]() |
登录 |
#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("\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=getch())=='y') goto loop; } 网址为:http://www.vcok.com/class/list.asp?id=212 [此贴被 ziaichen(ziaichen) 在 12月17日13时30分 编辑过] |
地主 发表时间: 12/17 13:42 |
![]() | 回复: sweetblood [sweetblood] ![]() |
登录 |
555555555555 看不太明白呀 我顶 谁能帮忙讲一下呀??? ![]() ![]() |
B1层 发表时间: 12/18 16:24 |
![]() | 回复: ceo_8008 [ceo_8008] ![]() |
登录 |
呵呵,我们的作业就有这道题 |
B2层 发表时间: 12/18 16:33 |
![]() | 回复: bluedomb [bluedomb] ![]() |
登录 |
哈哈。我能看懂一些了,可是我不知道time.h文件有什么作用 |
B3层 发表时间: 12/18 17:29 |
![]() | 回复: ceo_8008 [ceo_8008] ![]() |
登录 |
计算你做题的时间 |
B4层 发表时间: 12/19 13:10 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号