답안 #39452

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
39452 2018-01-15T14:08:51 Z smu201111192 비교 (balkan11_cmp) C++14
컴파일 오류
0 ms 0 KB
#include "cmp.h"
int bit_get(int addr)
{
    if(boiPhase == 1) {
        fprintf(stderr, "ZERO POINTS: bit_get called by remember()\n");
        exit(1);
    }
    //fprintf(stderr, " %d",addr);
    boiAccesses++;
    if((addr > 10240) || (addr < 1)) {
        fprintf(stderr, "ZERO POINTS: bit_get with address out of range\n");
        exit(1);
    }
    return boiMem[boi_guessval][addr]?1:0;
}

/* these are just prototypes that you must implement*/
void remember(int n){
    int a[4]; int pos = 3;
    while(pos >= 0){
        a[pos--] = (n % 8); n/=8;
    }
    int cur = 1;
    for(int i=0;i<4;i++){
        cur = cur * 8 + a[i];
        bit_set(cur);
    }
}
int compare(int b) {
    int n = b;
    int a[4]; int pos = 3;
    while(pos >= 0){
        a[pos--] = (n % 8); n/=8;
    }
    int cur = 1; int i = 0;
    for(;i<4;i++){
        cur = cur * 8 + a[i];
        int bit = bit_get(cur);
        if(!bit) break;
    }
    if(i == 4)return 0;
    cur /= 8;
    int chk = 0;
    for(int k = 1; k < 8 ;k++){
        int bit = bit_get(cur * 8+k);
        if(bit == 1) chk = k;
    }
    if(chk > a[i]) return -1;
    return 1;
}

Compilation message

cmp.cpp: In function 'int bit_get(int)':
cmp.cpp:4:8: error: 'boiPhase' was not declared in this scope
     if(boiPhase == 1) {
        ^~~~~~~~
cmp.cpp:5:17: error: 'stderr' was not declared in this scope
         fprintf(stderr, "ZERO POINTS: bit_get called by remember()\n");
                 ^~~~~~
cmp.cpp:5:9: error: 'fprintf' was not declared in this scope
         fprintf(stderr, "ZERO POINTS: bit_get called by remember()\n");
         ^~~~~~~
cmp.cpp:6:9: error: 'exit' was not declared in this scope
         exit(1);
         ^~~~
cmp.cpp:9:5: error: 'boiAccesses' was not declared in this scope
     boiAccesses++;
     ^~~~~~~~~~~
cmp.cpp:11:17: error: 'stderr' was not declared in this scope
         fprintf(stderr, "ZERO POINTS: bit_get with address out of range\n");
                 ^~~~~~
cmp.cpp:11:9: error: 'fprintf' was not declared in this scope
         fprintf(stderr, "ZERO POINTS: bit_get with address out of range\n");
         ^~~~~~~
cmp.cpp:12:9: error: 'exit' was not declared in this scope
         exit(1);
         ^~~~
cmp.cpp:14:12: error: 'boiMem' was not declared in this scope
     return boiMem[boi_guessval][addr]?1:0;
            ^~~~~~
cmp.cpp:14:19: error: 'boi_guessval' was not declared in this scope
     return boiMem[boi_guessval][addr]?1:0;
                   ^~~~~~~~~~~~