<Windows.h> 랑 Sleep(1000) 조합 말고,
1초를 기다릴 수 있는 방법이 뭘까?
int main(){
clock_t start = clock();
int savetime = time(NULL);
while(time(NULL)-savetime < 1){
//반복
}
clock_t end = clock();
double result = (double)(end - start);
cout << result / CLOCKS_PER_SEC << endl;
return 0;
}
int main(){
clock_t start = clock();
int savetime = time(NULL);
while((clock()-start)/CLOCKS_PER_SEC < 1){
//반복
}
clock_t end = clock();
double result = (double)(end - start);
cout << result / CLOCKS_PER_SEC << endl;
return 0;
}
int main(){
clock_t start = clock();
long long int i = 0;
while(i < 1660000000){
//반복
i++;
}
clock_t end = clock();
double result = (double)(end - start);
cout << result / CLOCKS_PER_SEC << endl;
return 0;
}