赞
踩
}
对比运行时间
#include<iostream>
#include<unistd.h>
#include<time.h>
using namespace std;
class Complex
{
public:
Complex(double a,double b):r(a),c(b){}
private:
double r;
double c;
};
int main()
{
time_t start,end;
start = time(NULL);
Complex* array[1000];
for(int i =0;i < 50000;i++ )
{
for(int j = 0;j < 1000;j++)
{
array[j] = new Complex(i,j);
}
for(int j = 0;j < 1000;j++)
{
delete array[j];
}
}
end = time(NULL);
cout<<"time "<<difftime(end,start)<<endl;
return 0;
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。