#include<iostream>
#include<math.h>
#include<time.h>
using namespace std;
int main() {
clock_t start1;
clock_t start2;
clock_t end1;
clock_t end2;
start1 = clock();
for (int i = 0; i < 9000009; i++) {
double d = sqrt(200 * 200 + 200 * 200);
}
end1 = clock();
cout << double(end1 - start1) / CLOCKS_PER_SEC;
cout << endl;
start2 = clock();
for (int i = 0; i < 9000009; i++) {
double d = abs(1000-100)+abs(-1040-20);
}
end2 = clock();
cout << double(end2 - start2) / CLOCKS_PER_SEC;
cout << endl;
getchar();
return 0;
}
time部分代码运用,clock,时间
最新推荐文章于 2024-07-24 14:05:37 发布