Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
小小的纪念一下,poj上第30题。贴一下代码!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator