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

笨方法,但能想到的数据都过过了,怎么一直wa,求教!!!!!

Posted by xulinxi at 2010-08-17 11:50:19 on Problem 3617
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
	
	int n,i,k=0,p,j,flag=0;
	char a[3000],b[3000];
	
       scanf("%d",&n);
       
	
		for(i=0;i<n;i++)
	scanf("\n%c",&a[i]);

	
	p=0;
	for(i=0;i<n;++i)
	{
		if(flag)
	{
		i--;
	}
	if(p==n)
	break;
	for(j=n-1-k;j>=0;j--)
	{
		if(a[i]>a[j])
		{
			b[p]=a[j];
			p++;
			flag=1;
			k++;
			break;
		}
		if(a[i]==a[j]&&(i!=j))
		{
			if(a[i+1]>a[j-1])
			{
				b[p]=a[j];
				p++;
				flag=1;
				k++;
				break;
			}
			b[p]=a[i];
			p++;
			flag=0;
			break;
		}
		 b[p]=a[i];
		 p++;
		 flag=0;
	     break;
	}
	}
	for(i=0;i<n;i++)
	{
		if(i%80==79)
		printf("\n");
		printf("%c",b[i]);
		
	}
	
	
	return 0;
}

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