time1(), time2()
(高顯忠, sjgau4311@gmail.com, 2011-04-28 16:24)
1樓
#if 0
2000000000, -1973237248, 8.453
1000000000, -243309312, 4.125
500000000, -2083310976, 2.110
250000000, -1532069568, 1.109
125000000, 1795716256, 0.531
62500000, 1538295888, 0.235
31250000, -681355352, 0.125
15625000, -1240174412, 0.078
7812500, 1839393170, 0.031
3906250, 1534566679, 0.016
1953125, 384129951, 0.000
976562, 95788347, 0.000
488281, -1049672667, 0.015
244140, -262479202, 0.000
122070, -1139331107, 0.000
61035, 1862666130, 0.000
30517, 465658903, 0.000
15258, 116410911, 0.000
7629, 29104635, 0.000
3814, 7275205, 0.000
1907, 1819278, 0.000
953, 454581, 0.000
476, 113526, 0.000
238, 28441, 0.000
119, 7140, 0.000
59, 1770, 0.000
29, 435, 0.000
14, 105, 0.000
7, 28, 0.000
3, 6, 0.000
1, 1, 0.000
Press any key to continue
#endif
// --------------------------------------------------------
#include "sj-01.h"
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int no, sum, i, t1;
double dt;
no= (int) (20.0E8 + 0.5);
while (no > 0) {
time1(&t1);
sum= 0;
for (i=1;i<=no;i++) {
sum+= i;
}
time2(t1, &dt);
printf("%12ld, %12ld, %10.3lf \n", no, sum, dt);
no/= 2;
}
return EXIT_SUCCESS;
}// end of main()