TOPIC

10% de erro, codigo ta rodando

Luciano asked 1 year ago

include

using namespace std;

int main(){ int n, h=1, x=0; bool c=false; cin >> n; int N[n]; for (int i=0; i<n; i++){ cin >> N[i]; } if (n%2==0){ if (n==2){ if (N[0]!=N[1]){ c=true; } } if (N[0]<N[1] && N[n-1]>N[n-2]){ for (int s=1; s<=n-3; s=s+2){ if(N[s]>N[s+1] && N[s]>N[s-1]){ c=true; } } } if (N[0]>N[1] && N[n-1]<N[n-2]){ for (int s=1; s<=n-3; s=s+2){ if(N[s]<N[s+1] && N[s]<N[s-1]){ c=true; } } } } if (n%2!=2){ if (n==3){ if(N[0]<N[1] && N[1]>N[2]){ c=true; } if(N[0]>N[1] && N[1]<N[2]){ c=true; } } if (N[0]<N[1] && N[n-1]<N[n-2]){ for (int s=1; s<=n-3; s=s+2){ if(N[s]>N[s+1] && N[s]>N[s-1]){ c=true; } } } if (N[0]>N[1] && N[n-1]>N[n-2]){ for (int s=1; s<=n-3; s=s+2){ if(N[s]<N[s+1] && N[s]<N[s-1]){ c=true; } } } } if (c==true){ cout << 1 << endl; } if (c==false){ cout << 0 << endl; } }

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

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