首页 > 其他 > 详细

hdu 5264 pog loves szh I

时间:2015-06-08 19:15:20      阅读:194      评论:0      收藏:0      [点我收藏+]

题目连接

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.

技术分享
 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 }
View Code

 

 

hdu 5264 pog loves szh I

原文:http://www.cnblogs.com/GadyPu/p/4561480.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!