Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

我自己怎么测试都发现没错呀!!

Posted by poiulkj at 2007-05-03 17:04:43 on Problem 3183
In Reply To:哪位高手帮我测试测试,看看为什么WA.谢谢!!!!!(C++) Posted by:poiulkj at 2007-05-03 17:03:33
> #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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator