코드 시간 측정

dldzm·2021년 1월 28일
0

알고리즘을 채점 받기 전에 항상 시간 조건이 맞았는지 확인해야 할 때가 있다.

#include <time.h>
 
int main() {
    clock_t start, end;
    double result;
    int i,j;
    int sum = 0;
    //시간 측정 시작
    start = clock(); 

    //코드
    //시간 측정 끝
    end = clock(); 
    result = (double)(end - start);
    cout << "걸린 시간 : " << result;
    return 0;
}

제일 짜증날 때는 이렇게 측정해서 시간까지 맞췄음에도 불구하고 틀리는 경우이다. ㅎ..

profile
🛰️ 2021 fall ~

0개의 댓글