c语言例及教程c语言案例 ( cases of c language and tutorial c language case )

c语言例及教程c语言案例 ( cases of c language and tutorial c language case )

ID:15276749

大小:23.57 KB

页数:28页

时间:2018-08-02

c语言例及教程c语言案例 ( cases of c language and tutorial c language case )_第1页
c语言例及教程c语言案例 ( cases of c language and tutorial c language case )_第2页
c语言例及教程c语言案例 ( cases of c language and tutorial c language case )_第3页
c语言例及教程c语言案例 ( cases of c language and tutorial c language case )_第4页
c语言例及教程c语言案例 ( cases of c language and tutorial c language case )_第5页
资源描述:

《c语言例及教程c语言案例 ( cases of c language and tutorial c language case )》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、c语言100例及教程c语言案例10(100casesofClanguageandtutorialclanguagecase10)==91--100:.:classicCprogram100cases:ClassicCprogram:100casesof==91--100[program91]Title:timefunctionexample11.programanalysis:2.programsourcecode:#include"stdio.h""#include"time.h""Voidmain(){time_tlt;/*defineaLon

2、ginttimevarible*/Lt=time(NULL);/*systemtimeanddate*/Printf(CTime(<));/*englishformatoutput*/Printf(asctime(Localtime(<)));/*tranfertotm*/Printf(asctime(gmtime(<)));/*tranfertoGreenwichtime*/}==============================================================[program92]Title:timefun

3、ctionexample21.programanalysis:2.programsourcecode:/*calculatetime*/#include"time.h""#include"stdio.h""(main){time_tstart,end;Inti;Start=time(NULL);For(i=0;i<3000;i++){printf("1111111111");}End=time(NULL);Printf("1:Thedifferentis%6.3f",difftime(end,start));}====

4、==========================================================[program93]Title:timefunctionexample31.programanalysis:2.programsourcecode:/*calculatetime*/#include"time.h""#include"stdio.h""(main){clock_tstart,end;Inti;Doublevar;Start=clock();For(i=0;i<10000;i++){printf("11111

5、11111");}End=clock();Printf("1:Thedifferentis%6.3f",(double)(end-start);}==============================================================[program94]Title:timefunctionexample4,aguessinggame,judgeaperson'sreactionspeed.(moderatorsarebeginners.)1.programanalysis:2.program

6、sourcecode:#include"time.h""#include"stdlib.h""#include"stdio.h""(main){charc;Clock_tstart,end;Time_ta,b;Doublevar;Inti,guess;Srand(time(NULL));Printf("doyouwanttoplayit.('y'or'n')");Loop:While((c=getchar())=='y'){I=rand()%100;Printf("pleaseinputnumberyouguess:");Start=c

7、lock();A=time(NULL);Scanf("%d",&guess);While(guess!=i){if(guess>i){printf("pleaseinputalittlesmaller.");Scanf("%d",&guess);}Else{printf("pleaseinputalittlebigger.");Scanf("%d",&guess);}}End=clock();B=time(NULL);Printf("1:Ittookyou%6.3fseconds",var=(double)(end-start)/18

8、.2);Printf("1:ittookyou%6.3fseconds",difftime(B,a));If(v

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。