UVA10851 2D Hieroglyphs decoder【文本】

Steganography is one of the most famous techniques for hiding information in different places, including images. Recently, for example, Xerox announced they were releasing a 2D-hieroglyphs that were able to codify a message within them. Your task is to decipher a 2D-hieroglyph.
    A 2D hieroglyph is a matrix H of 10 rows and M + 2 columns that encode a message of length M characters (c0, c1, . . . , cM−1). The matrix H has the following lattice:
在这里插入图片描述
where
在这里插入图片描述
and c is the ASCII value of the character passed to the b function.
    Your task is to find the message given the matrix H.
Input
The input is composed of a first line with a number N indicating the number of messages to decode, followed by N matrices separated by a “newline” character. The length of any message will not be more than 80 characters.
Output
The output must have N messages, one per each matrix given in the input.
Sample Input
2
///
//\///\\///\/
///
///\\///\//\/\\//\//
///\/\\//
//\/
/
/\/\\\/\/\\\/\/\/\\\\/
///
///
///
//
//\//\///
\\///
\/
///
/\\\\/
/\\\\/
///
///
Sample Output
LA LLUVIA EN SEVILLA ES UNA MARAVILLA
abcdefghi

问题链接UVA10851 2D Hieroglyphs decoder
问题简述:(略)
问题分析
    。
    。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA10851 2D Hieroglyphs decoder */

#include <bits/stdc++.h>

using namespace std;

int convert[]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
const int H = 10;
const int L = 80;
char b[H][L + 1];

char mychar(int k, char c)
{
    return c / convert[k] % 2 ? 92 : 47;
}

int main()
{
    int t;
    scanf("%d", &t);
    while(t--) {
        getchar();
        for(int i = 0; i < H; i++)
            gets(b[i]);
        int end = strlen(b[0]) - 2;
        for(int i = 1; i <= end; i++) {
            for(char c = ' '; c <= 'z'; c++) {
                bool flag = true;
                for(int j = 1; j <= H - 2; j++)
                    if(mychar(j - 1, c) != b[j][i]) {
                        flag = false;
                        break;
                    }
                if(flag) {
                    putchar(c);
                    break;
                }
            }
        }
        putchar('\n');
    }

    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值