//计算运行该程序所需的时间
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define CLOCKS_PER_SEC ((clock_t)1000)//表示精度到毫秒
//很明显,clock_t是一个长整形数。在time.h文件中,还定义了一个常量CLOCKS_PER_SEC,
//它用来表示一秒钟会有多少个时钟计时单元(精度可以自己定义,但是注意,在标准C/C++中,最小的计时单位是一毫秒)
void timestart()
{
long i = 0;
clock_t start = 0;
start = clock();// clock()是C/C++中的计时函数,而与其相关的数据类型是clock_t
}
void timeend()
{
double t = 0.00;
clock_t start = 0;
clock_t end = 0;
end = clock();
//把结果转化成double型
t = (double)(end - start) / CLOCKS_PER_SEC;
printf("%lf seconds is used\n", t);
}
int main (void)
{
int i;
timestart();//在程序开始时开始计时
for(i = 1; i <= 10000; i++)
printf("%5d",2);