TOPIC

Compilation error (?)

Gabriel Henrique Schumacher asked 1 year ago

Why compilation error? In my computer everything is normal..

#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int vet[n], teste = 0;
    for(int i=0; i<n ; i++)
        scanf("%d", &vet[i]);
    if(vet[0]<vet[1]){
        for(int i=2; i<n; i++){
            if(i%2==0){
                if(vet[i]<vet[i-1])
                    teste = 1;
                else{
                    teste = 0;
                    break;
                }
            }else{
                if(vet[i]>vet[i-1])
                    teste = 1;
                else{
                    teste = 0;
                    break;
                }
            }
        }
    }else if(vet[0]>vet[1]){
        for(int i=2; i<n; i++){
            if(i%2==0){
                if(vet[i]>vet[i-1])
                    teste = 1;
                else{
                    teste = 0;
                    break;
                }
            }else{
                if(vet[i]<vet[i-1])
                    teste = 1;
                else{
                    teste = 0;
                    break;
                }
            }
        }
    }

    if(teste==1)
        printf("1\n");
    else
        printf("0\n");

    return 0;
}

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.