ZOJ 3121 Arne Saknussemm

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

字符串解密水题.

最后一列注意一下就可以.

#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;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值