#include<ctime>
#include<iostream>
#include<vector>
#include<deque>
#include<algorithm>
#include<cstdlib>
using namespace std;
void main()
{
time_t start,finish;
vector<int>v(10000);
int i=0;
start=time(0);
while(i<10000)
{v.insert(v.begin(),100);i++;}
finish=time(0);
cout<<"vector's front time:"<<difftime(finish,start)<<endl;
deque<int>d(10000);
int j=0;
start=time(0);
while(j<10000)
{d.insert(d.begin(),100);j++;}
finish=time(0);
cout<<"deque's front time:"<<difftime(finish,start)<<endl;
//cout<<ctime(&start)<<endl;//输出当前时间
time_t starter,finisher;
vector<int>ve(10000);
int n=0;
starter=time(0);
while(n<10000)
{ve.insert(ve.end(),100);n++;}
finisher=time(0);
cout<<"vector's end time:"<<difftime(finisher,starter)<<endl;
deque<int>de(10000);
int m=0;
starter=time(0);
while(m<10000)
{de.insert(de.end(),100);m++;}
finisher=time(0);
cout<<"deque's end time:"<<difftime(finisher,starter)<<endl;
}
本来difftime(finisher,starter)返回的是一个double类型的数据,但是为什么输出的却是一个整数呢?