uva10701

来源:互联网 发布:慈溪行知职校电话 编辑:程序博客网 时间:2024/06/11 14:54
#include <iostream>#include <string>#include <string.h>using namespace std;void slove(char*,char*,int);int main(){char pr[60], in[60];int T, n;string str;cin >> T;while (T--){cin >> n;cin >> str;strcpy(pr,str.c_str());cin >> str;strcpy(in, str.c_str());slove(pr,in,n);cout << endl;}}void slove(char *pr, char *in, int length){if (length == 0)return;char a = *pr;int rootIndex = 0;for (; rootIndex < length; rootIndex++){if (in[rootIndex] == *pr)break;}slove(pr + 1, in, rootIndex);slove(pr + rootIndex + 1, in + rootIndex + 1, length - rootIndex - 1);cout <<a;}

0 0
原创粉丝点击