hdu 5264 pog loves szh I
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5264
pog loves szh I
Description
Pog has lots of strings. And he always mixes two equal-length strings. For example, there are two strings: "abcd" and "efgh". After mixing, a new string "aebfcgdh" is coming.
However, szh thinks it is boring, so he reverses the second string, like changing "efgh" to "hgfe". Then mix them as usual, resulting in "ahbgcfde".
Now, here comes a problem. Pog is given a string after mixing by szh, but he wants to find the original two strings.
Hint : In this question, it needs a linefeed at the end of line at hack time.
Input
The first line has an integer, $T(1 \leq T \leq 100)$, indicating the number of cases.
Then follows T lines. Every lines has a string S, whose length is even and not more than 100, and only consists of lower-case characters('a'~'z').
Output
For each cases, please output two lines, indicating two original strings.
Sample Input
1
aabbca
Sample Output
abc
aba
For example, there are two strings: "abcd" and "efgh". After mixing, a new string "aebfcgdh" is coming.
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<algorithm> 2 #include<iostream> 3 #include<string> 4 using std::cin; 5 using std::cout; 6 using std::endl; 7 using std::string; 8 int main() { 9 #ifdef LOCAL 10 freopen("in.txt", "r", stdin); 11 freopen("out.txt", "w+", stdout); 12 #endif 13 std::ios::sync_with_stdio(false); 14 int t; 15 cin >> t; 16 while (t--) { 17 string s1, s2, buf; 18 cin >> buf; 19 for (int i = 0; buf[i]; i++) { 20 if (i & 1) s2 = buf[i] + s2; 21 else s1 += buf[i]; 22 } 23 cout << s1 << endl << s2 << endl; 24 } 25 return 0; 26 }
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步