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

哪位大牛能帮菜鸟看一下那儿错了吗?不胜感激!!c语言的。。。

Posted by 312370233 at 2008-07-09 14:56:41 on Problem 3623
是我理解错题意了还是????
#include<stdio.h>
#define N 30000
void main()
{
	int n,i,j;
	char s[N+10];
	scanf("%d",&n);
        for(i=0;i<n;)
		if((s[i]=getchar())!='\n')
			i++;
        i=0;
	j=n-1;
	if(i==j) printf("%c\n",s[i]);
	else
	{
	for(;i<j;)
	{
		if(s[i]<s[j])
			printf("%c",s[i++]);
		else if(s[i]>s[j])
			printf("%c",s[j--]);
		else
		{
			if(s[i]<s[i+1]&&s[i]<s[j-1])
				printf("%c%c",s[i++],s[j--]);
			else if(s[i+1]<=s[j-1])
				printf("%c",s[i++]);
			else
				printf("%c",s[j--]);
		}
	}
	if(i==j)
	     printf("%c\n",s[i]);
	}
}

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