Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
why is it wrong?#include<stdio.h> #define N 50001 int main() { unsigned int i,n; int h[N]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&h[i]); } for(i=0;i<n-1;) { if(h[i]==h[i+1]) { printf("%d\n",i+1); i++; } else if(h[i]>h[i+1]) { printf("%d\n",i+1); i++; while(i<n-1&&h[i]>h[i+1]) { i++; } i++; } else { i++; while(i<n-1&&h[i]<h[i+1]) { i++; } printf("%d\n",i+1); if(h[i]==h[i+1]) { i++; } else { while(i<n-1&&h[i]>h[i+1]) { i++; } i++; } } } if(h[n-2]==h[n-1]) printf("%d\n",n); return(0); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator