Compilation Error on C++ and Accepted on C

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
pavelph
Learning poster
Posts: 57
Joined: Wed Dec 10, 2003 7:32 pm
Location: Russia, Saint-Petersburg

Compilation Error on C++ and Accepted on C

Post by pavelph » Sat Jan 01, 2005 6:44 pm

I recently started to use C/C++ and as I know most of programs that work on C also work on C++ (at least compile). Maybe you can tell me what in this program can produce CE on C++(I use Visual C++ 6 and all work).

Code: Select all

//This is problem 10714
//It's AC on C and Compilation Error on C++ (why??)
#include <stdio.h>
int main(){
    int NT, T;
    int L, N;
    int i, min, max, x, mini, maxi;
    const big = 2000000;
    scanf("%i", &NT);
    for (T = 1; T <= NT; T++){
        scanf("%i%i", &L, &N);
        min = -big;
        max = -big;
        for (i = 1; i <= N; i++){
            scanf("%i", &x);
            if (x > L - x){
                mini = L - x;
                maxi = x;
            }
            else{
                mini = x;
                maxi = L - x;
            }
            if (mini > min) min = mini;
            if (maxi > max) max = maxi;
        }
        printf("%i %i\n", min, max);
    }
    return 0;
}

User avatar
UFP2161
A great helper
Posts: 277
Joined: Mon Jul 21, 2003 7:49 pm
Contact:

Post by UFP2161 » Sun Jan 02, 2005 2:08 am

test.cpp: In function `int main()':
test.cpp:8: ANSI C++ forbids declaration `big' with no type

Post Reply

Return to “C++”