我需要用c/c++实现计算两个系统时间的间隔的程序,请教大家,非常感谢!!!

来源:百度知道 编辑:UC知道 时间:2024/06/07 12:06:26
希望大家给一个能直接运行的程序,谢谢!!
关于程序的一点解释:
程序刚开始的时候有个系统时间,中间调用其它的子模块,结束后又有一个系统时间,要求计算这个子模块运行的时间。

前些天老师布置的计算排序的效率恰好用上了我也发下
#include <iostream.h>
#include<windows.h>

template<typename Type>
inline void Swap(Type* array, int x, int y)
{
Type temp;
temp=array[x];
array[x]=array[y];
array[y]=temp;
}
//直接选择排序
template<typename Type>
void select(Type *array, int low, int high)
{
int pos;
for(int i=low; i<high; i++){
pos=i;
for(int j=i+1; j<=high; j++)
if(array[pos]>array[j]) pos=j;
if(i!=pos)Swap(array,i,pos);
}
}

int main()
{
int t1a,t1b,max;
int a[100000];
while(max>100000||max<0)
{
cout<<"Input the max of the array(0<=max<=100000)"<<endl;
cin>>max;
}
for(int m=0;m<=max;m++)
{
a[m]=rand()%10000;//设置a[]在0~10000之间
}
t1a=GetTickCount();