C/C++の宿題を片付けます 104代目 at TECH
[2ch|▼Menu]
484:デフォルトの名無しさん
08/02/29 01:11:21
>>482
全文字列を展開してソートした場合

#include <iostream>
#include <string>
#include <set>
#include <time.h>
using namespace std;

class gou{
public: string str; int num;
gou(string a, int b){str=a; num=b;}
bool operator<(const gou& a)const{return str<a.str;}};

main(){
int sz=20000,n;
string a(sz,'\0');
for(n=0;n<sz;n++)a[n]=rand()&255;

multiset<gou> s;
int cl=clock();
for(n=0;n<sz;n++){ s.insert(gou(a,n)); a=a.substr(1)+a[0];}
cl=clock()-cl; cout<<"20kのブロックーソート "<<(cl+0.0)/1000<<"sec \n";
}


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

4969日前に更新/299 KB
担当:undef