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 |
Re:留个纪念(第一次哦)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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator