Compilation Error on C++ and Accepted on C

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

Moderator: Board moderators

Post Reply
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 »

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;

A great helper
Posts: 277
Joined: Mon Jul 21, 2003 7:49 pm

Post by UFP2161 »

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

Post Reply

Return to “C++”