답안 #39759

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
39759 2018-01-18T09:15:10 Z krauch 비교 (balkan11_cmp) C++14
컴파일 오류
0 ms 0 KB
#include "cmp.h"

#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)

void remember(int n) {
    forn(i, 0, 11) {
        if (bit(n, i)) bit_set(i + 1);
    }
}

int compare(int b) {
    int cnt = 0;
    forn(i, 0, 11) {
        cnt += (bit_get(i + 1) << i);
    }
    if (cnt == b) return 0;
    if (cnt > b) return -1;
    if (cnt < b) return 1;
}

Compilation message

cmp.cpp: In function 'void remember(int)':
cmp.cpp:8:13: error: 'bit' was not declared in this scope
         if (bit(n, i)) bit_set(i + 1);
             ^~~
cmp.cpp: In function 'int compare(int)':
cmp.cpp:20:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^