经典C语言程序设计100例(9)
【程序91】
标题:时间函数1的例子
1。程序分析:
2。程序源代码:
# include " stdio . h "
# include " time . h "
。/*定义一个长时间变量*/
lt = time(NULL);/*系统时间和日期*/
printf(ctime(printf(ASC time(local time(printf(ASC time(gmtime(}
-。br/]/* calculate time */
# include " time . h "
# include " stdio . h "[br/]main()
{ time _ t start,end
int I;
start=time(空);
for(I = 0;I { printf(" \ 1 \ 1 \ 1 \ 1 \ 1 \ 1 \ 1 \ 1 \ n ");}
end = time(NULL);
printf(":不同的是%6.3f\n ",difftime(end,start));
}
-。2.程序源代码:
/* calculate time */
# include " time . h "
# include " stdio . h "
main()
{ clock _ t start,end
int I;
双var
start = clock();
for(I = 0;I { printf(" \ 1 \ 1 \ 1 \ 1 \ 1 \ 1 \ 1 \ 1 \ n ");}
end = clock();
printf(":不同的是%6.3f\n ",(double)(end-start));
}
0条评论