답안 #14951

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14951 2015-07-07T12:36:31 Z ztehgns 볼질 (OJUZ10_ballparade) C++
컴파일 오류
0 ms 0 KB
#include <stdio.h>

void chkpush(bool*);
void push(bool*);

int ballcount;

int main(){
    int n, ord. score=0
    bool base[4];
    base[0] = base[1] = base[2] = base[3] = false;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        scanf("%d", &ord);
        switch(ord){
        case 1:
            ballcount++;
            break;
        case 2:
            ballcount = 0;
            push(base);
            break;
        case 3:
            ballcount++;
            chkpush(base);
            break;
        }
        if(ballcount==4)
            ballcount = 0, push(base);
        if(base[0]) base[0] = false, score++;
    }
    printf("%d\n", score);
    return 0;
}

void chkpush(bool* base){
    if(base[3])
        base[0] = true, base[3] = false;
    if(base[2])
        base[3] = true, base[2] = false;
    if(base[1])
        base[2] = true, base[1] = false;
}

void push(bool* base){
    if(base[3] && base[2] && base[1])
        base[0] = true, base[3] = false;
    if(base[2] && base[1])
        base[3] = true, base[2] = false;
    if(base[1])
        base[2] = true, base[1] = false;
}

Compilation message

ballparade.cpp: In function ‘int main()’:
ballparade.cpp:9:15: error: expected initializer before ‘.’ token
     int n, ord. score=0
               ^
ballparade.cpp:11:5: error: ‘base’ was not declared in this scope
     base[0] = base[1] = base[2] = base[3] = false;
     ^
ballparade.cpp:14:22: error: ‘ord’ was not declared in this scope
         scanf("%d", &ord);
                      ^
ballparade.cpp:30:38: error: ‘score’ was not declared in this scope
         if(base[0]) base[0] = false, score++;
                                      ^
ballparade.cpp:32:20: error: ‘score’ was not declared in this scope
     printf("%d\n", score);
                    ^
ballparade.cpp:12:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^