标签:sicily
链接:http://soj.me/show_problem.php?pid=1007
5 toioynnkpheleaigshareconhtomesnlewx 3 ttyohhieneesiaabss 0
theresnoplacelikehomeonasnowynightx thisistheeasyoneab
解题思路:
按照加密的方式还原回去就可以了;
代码如下:
// Problem#: 1007
// Submission#: 2815109
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define MAXN 205
#define RST(N)memset(N, 0, sizeof(N))
using namespace std;
int columns;
char str[MAXN];
int len, cnt, temp, step;
void Init()
{
scanf("%s", str);
len = strlen(str);
cnt = 0;
}
int main()
{
while(~scanf("%d", &columns) && columns) {
Init();
for (int i=0, j=0; cnt<len; i++) {
temp = 2*columns*i + j;
if(temp < len) {
putchar(str[temp]);
cnt++;
}else {
i = -1;
j++;
continue;
}
temp = 2*columns*(i+1) - 1 - j;
if (cnt < len && temp < len) {
putchar(str[temp]);
cnt++;
}else {
i = -1;
j++;
}
}
puts("");
}
return 0;
} 标签:sicily
原文地址:http://blog.csdn.net/keshacookie/article/details/24666715