답안 #205035

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
205035 2020-02-27T17:42:33 Z alexandra_udristoiu 비교 (balkan11_cmp) C++14
컴파일 오류
0 ms 0 KB
#include<iostream>
#include "cmp.h"
using namespace std;
int v[] = {0, 10, 10, 8, 6};
int p[] = {0, 6400, 640 ,64 ,6, 1}
void remember(int a){
    for(int i = 4; i >= 1; i--){
        bit_set(a);
        a /= v[i];
    }
}
int compare(int b){
    int i, x, st, dr;
    for(i = 1; i <= 4; i++){
        x = b / p[i + 1];
        if(get_bit(x) == 0){
            break;
        }
    }
    if(i == 5){
        return 0;
    }
    st = x - x % v[i];
    dr = st + v[i] - 1;
    if(x - st < dr - x){
        for(i = st; i < x; i++){
            if(get_bit(i) == 1){
                return 1;
            }
        }
        return -1;
    }
    else{
        for(i = dr; i > x; i--){
            if(get_bit(i) == 1){
                return -1;
            }
        }
        return 1;
    }
}

Compilation message

cmp.cpp:6:1: error: expected ',' or ';' before 'void'
 void remember(int a){
 ^~~~
cmp.cpp: In function 'int compare(int)':
cmp.cpp:16:12: error: 'get_bit' was not declared in this scope
         if(get_bit(x) == 0){
            ^~~~~~~
cmp.cpp:16:12: note: suggested alternative: 'getpt'
         if(get_bit(x) == 0){
            ^~~~~~~
            getpt
cmp.cpp:27:16: error: 'get_bit' was not declared in this scope
             if(get_bit(i) == 1){
                ^~~~~~~
cmp.cpp:27:16: note: suggested alternative: 'getpt'
             if(get_bit(i) == 1){
                ^~~~~~~
                getpt
cmp.cpp:35:16: error: 'get_bit' was not declared in this scope
             if(get_bit(i) == 1){
                ^~~~~~~
cmp.cpp:35:16: note: suggested alternative: 'getpt'
             if(get_bit(i) == 1){
                ^~~~~~~
                getpt