time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Polycarp loves ciphers. He has invented his own cipher called Right-Left.
Right-Left cipher is used for strings. To encrypt the string s=s1s2…sns=s1s2…sn Polycarp uses the following algorithm:
For example, if ss="techno" the process is: "t" →→ "te" →→ "cte" →→ "cteh" →→ "ncteh" →→ "ncteho". So the encrypted ss="techno" is "ncteho".
Given string tt — the result of encryption of some string ss. Your task is to decrypt it, i.e. find the string ss.
Input
The only line of the input contains tt — the result of encryption of some string ss. It contains only lowercase Latin letters. The length of tt is between 11 and 5050, inclusive.
Output
Print such string ss that after encryption it equals tt.
Examples
input
Copy
ncteho
output
Copy
techno
input
Copy
erfdcoeocs
output
Copy
codeforces
input
Copy
z
output
Copy
z
分一下字符串的奇偶模拟即可,注意要用char 不要用string
代码:
#include
#include
#include
#include
using namespace std;
int main() {
char str[10005],str1[10005];
scanf("%s",str);
int len=strlen(str);
int s=0;
if(len%2==0) {
for(int t=len/2-1; t>=0; t--) {
str1[s++]=str[t];
str1[s++]=str[len-1-t];
}
} else {
str1[s++]=str[len/2];
for(int t=len/2-1; t>=0; t--) {
str1[s++]=str[len-1-t];
str1[s++]=str[t];
}
}
for(int t=0; t