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

shui

Posted by KatrineYang at 2016-11-25 14:20:58 on Problem 2255
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;

void printPos(char *pre, char *in, int len){
	if(!len) return;
	char root = pre[0];
	int pos;
	for(int i = 0; i < len; i++){
		if(in[i] == root){
			pos = i;
			break;
		}
	}
	printPos(pre+1, in, pos);
	printPos(pre+1+pos, in+pos+1, len-pos-1);
	printf("%c", root);
}

int main() {
	char pre[30], in[30];
	while(scanf("%s%s", pre, in) == 2){
		int len = strlen(pre);
		printPos(pre, in, len);
		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