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

小小的纪念一下,poj上第30题。贴一下代码!

Posted by scse_1106_xzl at 2012-01-03 00:01:39 on Problem 2255
#include<stdio.h>
#include<string.h>
int j=0,len;
char a[27],b[27];
int getposition(char c)
{
	int i;
	for(i=0;i<len;i++)
		if(b[i]==c)
			return i;
}
void postorder(int s,int t)
{
	int mid;
	if(s==t)
	{
		printf("%c",b[s]);
		j++;
		return;
	}
	mid=getposition(a[j++]);
	if(s<=mid-1)
	    postorder(s,mid-1);
	if(mid+1<=t)
    	postorder(mid+1,t);
	printf("%c",b[mid]);
}	
void main()
{
	while(scanf("%s%s",a,b)!=EOF)
	{
		j=0;
		len=strlen(a);
		postorder(0,len-1);
		printf("\n");
	}
}

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