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 200908061078 at 2011-08-04 11:28:36 on Problem 3623
代码:

#include<stdio.h>
#include<string.h>
int main(int argc, char *argv[])
{
	int n,i,j,k,p,q,t,c=0;
	char a[30001];
	scanf("%d",&n);
	j=0;
	
	for(i=0;i<n;i++)
	{	
		getchar();
		scanf("%c",&a[i]);
	}
	k=n-1;
	while(j<=k)
	{
		if(a[j]>a[k])
		{
			
			printf("%c",a[k]);
			k--;
			c++;
		}	
		else
		{
			
			printf("%c",a[j]);
			j++;
			c++;
		}
		if(a[j]==a[k])
		{
			t = 1;
            p = j + 1; q = k - 1;
            while(p < q)
            {
                if(a[p] > a[q])
                    { t = 0; break; }
                else if(a[p] == a[q])
                    { p++; q--; }
                else break;
            }
            if(t) { printf("%c", a[j]); j++; c++; }
            else { printf("%c", a[k]); k--; c++; }
		}
		if(c%80==0) printf("\n");
	}
	printf("\n");
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