赌侠2之上海滩赌圣电影:请帮我解释一下c代码!

来源:百度文库 编辑:神马品牌网 时间:2024/05/01 12:35:07
(一)
#include "time.h"
#include "stdio.h"
main()
{ clock_t start,end;
int i;
double var;
start=clock();
for(i=0;i<10000;i++)
{ printf("\1\1\1\1\1\1\1\1\1\1\n");}
end=clock();
printf("\1: The different is %6.3f\n",(double)(end-start));
getch();
}
(二)
include "time.h"
#include "stdio.h"
main()
{ time_t start,end;
int i;
start=time(NULL);
for(i=0;i<3000;i++)
{ printf("\1\1\1\1\1\1\1\1\1\1\n");}
end=time(NULL);
printf("\1: The different is %6.3f\n",difftime(end,start));
}
getch();
}

#include "time.h"
#include "stdio.h" //头文件
main()
{ clock_t start,end; //定义两个时钟结构的变量,时钟结构已经在头文件 time.h中定义
int i; //整形变量i,用于循环
double var; //双精度变量,在程序中并没有使用
start=clock(); //得到起始时间
for(i=0;i<10000;i++)
{ printf("\1\1\1\1\1\1\1\1\1\1\n");} //循环10000次
end=clock(); //得到终止时间
printf("\1: The different is %6.3f\n",(double)(end-start));//输出时间差
getch();//等待键盘输入
}
这段程序的作用就是查看执行壹万次Printf语句所使用的时间。