- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
sort_test.c
资源名称:leda.tar.gz [点击查看]
上传用户:gzelex
上传日期:2007-01-07
资源大小:707k
文件大小:2k
源码类别:
数值算法/人工智能
开发平台:
MultiPlatform
- #include <LEDA/basic.h>
- #include <LEDA/list.h>
- #include <LEDA/array.h>
- main ()
- {
- int i;
- int N = read_int("N = ");
- float T = used_time();
- cout << "building arrays ";
- cout.flush();
- array<int> Ai(N);
- array<float> Af(N);
- array<double> Ad(N);
- for (i = 0; i < N; i++) Ad[i] = Af[i] = Ai[i] = rand_int(1,1000000);
- cout << string(" %5.3f sec",used_time(T));
- newline;
- cout << "building lists ";
- cout.flush();
- list<int> Li;
- list<float> Lf;
- list<double> Ld;
- for (i = 0; i < N; i++)
- { Li.append(Ai[i]);
- Lf.append(Af[i]);
- Ld.append(Ad[i]);
- }
- cout << string(" %5.3f sec",used_time(T));
- newline;
- newline;
- cout << "sorting array<int> ";
- cout.flush();
- Ai.sort();
- cout << string(" %5.3f sec",used_time(T));
- newline;
- cout << "sorting again ";
- cout.flush();
- Ai.sort();
- cout << string(" %5.3f sec",used_time(T));
- newline;
- cout << "sorting array<float> ";
- cout.flush();
- Af.sort();
- cout << string(" %5.3f sec",used_time(T));
- newline;
- cout << "sorting array<double>";
- cout.flush();
- Ad.sort();
- cout << string(" %5.3f sec",used_time(T));
- newline;
- newline;
- cout << "sorting list<int> ";
- cout.flush();
- Li.sort();
- cout << string(" %5.3f sec",used_time(T));
- newline;
- cout << "sorting again ";
- cout.flush();
- Li.sort();
- cout << string(" %5.3f sec",used_time(T));
- newline;
- cout << "sorting list<float> ";
- cout.flush();
- Lf.sort();
- cout << string(" %5.3f sec",used_time(T));
- newline;
- cout << "sorting list<double> ";
- cout.flush();
- Ld.sort();
- cout << string(" %5.3f sec",used_time(T));
- newline;
- newline;
- cout << "test sorting ";
- cout.flush();
- for(i=0;i<N;i++)
- { int x = Li.pop();
- float y = Lf.pop();
- double z = Ld.pop();
- if (x != y || y != z || z != Ai[i] || Ai[i] != Af[i] || Af[i] != Ad[i])
- cout << "ERRORn";
- }
- cout << string(" %5.3f sec",used_time(T));
- newline;
- return 0;
- }