Page 1 of 1

Compilation Error on C++ and Accepted on C

Posted: Sat Jan 01, 2005 6:44 pm
by pavelph
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;
                mini = x;
                maxi = L - x;
            if (mini > min) min = mini;
            if (maxi > max) max = maxi;
        printf("%i %i\n", min, max);
    return 0;

Posted: Sun Jan 02, 2005 2:08 am
by UFP2161
test.cpp: In function `int main()':
test.cpp:8: ANSI C++ forbids declaration `big' with no type