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 }