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 ic07063 at 2008-03-30 19:54:15 on Problem 1141
#include <stdio.h>
int main()
{
	int a,b,c,d,e,f,g,top=5;
	char l[7000],*s=l;
	int i[7000]={0};
	gets(s);
	for(;*s;s++)
	{
		switch(*s)
		{
		case'(':
			i[top]=1;
			top++;
			break;
		case'[':
			i[top]=2;
			top++;
			break;
		case')':
			if(i[top-1]==1)
			{
				top--;
				break;
			}
			else if(i[top-1]==2)
			{
				printf("]");
				top--;
				if(i[top-1]!=1)
					printf("(");
				else top--;
				break;
			}
			else
			{
				printf("(");
				break;
			}
		case']':
			if(i[top-1]==2)
			{
				top--;
				break;
			}
			else if(i[top-1]==1)
			{
				printf(")");
				top--;
				if(i[top-1]!=2)
					printf("[");
				else
					top--;
				break;
			}
			else
			{
				printf("[");
				break;
			}
		}
		printf("%c",*s);
	}
	for(b=top-1;b>=5;b--)
	{
		if(i[b]==2)
		{
			printf("]");
			top--;
		}
		if(i[b]==1)
		{
			printf(")");
			top--;
		}
	}
	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