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

数据很弱哈,一次AC (*^__^*)

Posted by Icanmey at 2008-11-07 20:42:47 on Problem 2255 and last updated at 2008-11-07 20:44:02
我的代码,请多指教:
#include<iostream>
using namespace std;
char s[30];
char t[30];
void p(int is,int js,int it,int jt)
{
	if(is==js)
	{
		cout<<s[is];
		return;
	}
	if(is>js||it>jt)
		return ;
	char root;
	int k;
	root=s[is];
	for(k=it;k<=jt;k++)
	{
		if(t[k]==root)
			break;
	}
	int l=k-it;
	p(is+1,is+l,it,k-1);
	p(is+l+1,js,k+1,jt);
	cout<<root;
}
int main()
{
	int lenth;
	while(cin>>s>>t)
	{
		getchar();
		lenth=strlen(s);
		p(0,lenth-1,0,lenth-1);
		cout<<endl;
	}
	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