uva536

来源:互联网 发布:慈溪行知职校电话 编辑:程序博客网 时间:2024/06/11 13:29
#include <iostream>#include <string>#include <string.h>using namespace std;void slove(char*,char*,int);int main(){char pr[60], in[60];string str1, str2;while (cin >> str1 >> str2){strcpy(pr,str1.c_str());strcpy(in, str2.c_str());slove(pr,in,str1.length());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
原创粉丝点击