字符串解密水题.
最后一列注意一下就可以.
#include <iostream>
#include <cstdio>
#include <string.h>
#include <memory.h>
using namespace std;
const int maxn = 1010;
char str[maxn];
int n;
int main(){
while(~scanf("%d", &n)){
scanf("%s",str);
int k = strlen(str);
for(int i = 1; i < n; ++i){
scanf("%s", &str[i * k]);
}
int row = strlen(str) / k;
for(int i = k - 1; i >= 0; --i){
int tmp = 0;
if(i == 0){
for(; tmp < k && str[tmp] == '_'; ++tmp);
}
for(int j = n - 1; j >= tmp; --j){
char & ch = str[j * k + i];
if(ch == '_'){
printf(" ");
}else if(ch == '\\'){
printf("\n");
}else{
printf("%c", ch);
}
}
}
printf("\n\n");
}
return 0;
}

本文介绍了一种字符串解密的方法,通过特定的排列方式重组字符,实现加密字符串的还原。文章提供了一个完整的C++实现示例,展示了如何读取输入并按指定模式解密输出。

342

被折叠的 条评论
为什么被折叠?



