>>539 ソースはこんな感じでした。要はSTLを使ってるか否かの差なんですけど。環境:VC++6.0(C/C++共にReleaseビルド)
----- C -----
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 100000
int compare(const void *a, const void *b){ return *(int*)a - *(int*)b; }
int main(void){
int a[N];
clock_t s = clock();
srand((unsigned int)time(NULL));
for(int i = 0; i < N; ++i){ a[i] = rand() % N; }
qsort(a, N, sizeof(int), compare);
printf("%f\n", (float)(clock() - s) / CLOCKS_PER_SEC);
return 0;
}
----- C++ -----
#include <iostream>
#include <vector>
#include <algorithm>
#include <time.h>
#define N 100000
using namespace std;
int main(void){
clock_t s = clock();
srand((unsigned int)time(NULL));
vector<int> a;
for(int i = 0; i < N; ++i){ a.push_back(rand() % N); }
sort(a.begin(), a.end());
cout << (float)(clock() - s) / CLOCKS_PER_SEC << endl;
return 0;
}