TOPIC

Wrong answer (5%), caso que da erro é n=2, 0 1

Luis Victor Porto Santos asked 10 months ago

include

int main(){ int i, n, v[105], cont=0, soma=0, anule=0; scanf("%d", &n); for(i=0;i<n;i++){ scanf("%d", &v[i]); } for(i=1;i<n;i=i+2){ if(v[i-1]>v[i] && v[i]<v[i+1]){ cont++; } else if(v[i-1]<v[i] && v[i]>v[i+1]){ soma++; } else if((v[i-1]<=v[i] && v[i]<=v[i+1])){ anule++; }else if (v[i-1]==v[i]){ anule++; }else if(v[i-1]>=v[i] && v[i]>=v[i+1]){ anule++; } } if(anule>0){ printf("0\n"); }else{ printf("1\n"); } return 0; }

This topic was solved and cannot recieve new replies.