(1)生成测试数据:
freopen("test.in","w",stdout);//将生成的随机测试数据写入到同文件夹下的test.in中,
如果没有该文件它也会自动建立
srand(time(NULL));//生成随机种子
rand()//产生随机数
(2)生成输出文件.out
在程序main函数里的最初两行加入
freopen("test.in","r",stdin);//输入文件
freopen("test.out","w",stdout);//输出文件
#include<time.h>//计时函数头文件
clock_t start, finish;
double duration;
start = clock();
/*程序执行体*/
finish = clock();
duration = (double)(finish - start) / CLOCKS_PER_SEC;
printf( "%f seconds\n", duration );