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

Re:留个纪念(第一次哦)

Posted by sunchy at 2014-08-06 18:21:58 on Problem 2255
In Reply To:留个纪念(第一次哦) Posted by:lanjiangzhou at 2012-04-11 21:20:06
你的代码真精练呀,学习了。顺便改了一个求先序的。

#include <stdio.h>
#include <string.h>
void build(int n, char* post, char* in){
	if (n <= 0) return;
	int p = strchr(in, post[n-1]) - in;
	printf("%c", post[n-1]);
	build(p, post, in);
	build(n - p - 1, post + p, in + p + 1);
}
int main(){
	char post[26] = { 0 };
	char in[26] = { 0 };
	while (scanf("%s %s", post, in) != EOF){
		int n = strlen(post);
		build(n, post, in);
		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