正在加载图片...
算法的后期测试:例子 插装im(的计时程序 void Time Search() {∥在1.1000中拽靈0,10,,90,100,200,…1000 inta[l001],n[20] for(intj=0;j=1000;++)叫=;∥a0=1,a2|= for(j=0;j<10;++){ n=10*j;n101=0,n{1=10,n12]=20 +10]=100*(+1); ∥n10}=100,n{11=200,n[12|=300 cout << n time"<< endI for(j=0;j20;j++){ long start, stop time(start); int k= seqsearch(a, nl], 0); time(stop) long runTime = stop-start; cout <<"<<n]<<"<< run Time < endl; cout << "Times are in hundredths of a second. " < endl;插装time()的计时程序 void TimeSearch ( ) { //在1..1000中搜索0,10,…,90,100,200,…,1000 int a[1001], n[20]; for ( int j=0; j<=1000; j++ ) a[j] = j; //a[0]=1, a[2]=2, … for ( j=0; j<10; j++ ) { n[j] = 10*j; //n[0]=0, n[1]=10, n[2]=20 n[j+10] = 100*( j+1 ); } //n[10]=100, n[11]=200, n[12]=300 ... cout << " n time" << endl; for ( j=0; j<20; j++ ) { long start, stop; time (start); int k = seqsearch (a, n[j], 0); time (stop); long runTime = stop - start; cout << " " << n[j] << " " << runTime << endl; } cout << "Times are in hundredths of a second." << endl; } 算法的后期测试:例子
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有