程序代码:
#include <stdio.h> #include <time.h> int main(void) { int i = 0; double j = 0; clock_t t1 = clock(); while (i++ < 1<<30) { j--; } printf("用时%f s\n", (double)(clock() - t1) / CLOCKS_PER_SEC); printf("结果%d\n", (int)(i + j)); return 0; }
不优化 看单纯跑循环效率有无差别