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 |
哪位高手帮我测试测试,看看为什么WA.谢谢!!!!!(C++)#include<iostream.h> #include<stdlib.h> int n,a[10001]; int cmp(const void *d, const void *b) { return(*(int *)b-*(int *)d); } void destroy(int i) { if(i>0&&a[i-1]!=0&&a[i-1]<a[i]) destroy(i-1); if(i<n-1&&a[i+1]!=0&&a[i+1]<a[i]) destroy(i+1); a[i]=0; } void main() { int i,j,b[10001],c[10001],x=-1; cin>>n; for(i=0;i<n;i++) cin>>a[i]; for(i=0;i<n;i++) b[i]=a[i]; qsort(b,n,sizeof(b[0]),cmp); for(j=0;j<n;j++) { for(i=0;i<n;i++) if(a[i]==b[j]) {destroy(i); x++; c[x]=i+1;} } qsort(c,x+1,sizeof(c[0]),cmp); for(j=x;j>=0;j--) cout<<c[j]<<endl; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator