一秒ずつ寝る sleep(1);
クロック数で時間を測る <ctime> clock()を使う。他プロセスがいると,time() と結果が異なる。 clock_t start,end; start = clock(); /* むにゃむにゃ */ end = clock(); cout << (double)(end-start) / CLOCKS_PER_SEC;
実時間で時間を測る <ctime> time()を使う。精度は clock() より低い。 time_t start,end; start = time(NULL); /* むにゃむにゃ */ end = clock(NULL); cout << (double)(end-start);