#include <iostream>
#include <string>
using namespace std;
int main()
{
int strwide;
cin >> strwide;
pair< char, char > rotor[][];
pair< char, char > rotor_instead[][];
string input;
int t = ; while( t < )
{
cin >> input;
if ( input.size() == strwide )
{
char start_1 = 'a';
char start_else = 'A';
if ( t == )
{
for ( int m = ; m < input.size(); m++ )
{
rotor[t][m].first = start_1;
rotor[t][m].second = input[m];
start_1 = start_1 + ;
}
}
else
{
for ( int m = ; m < input.size(); m++ )
{
rotor[t][m].first = start_else;
rotor[t][m].second = input[m];
start_else = start_else + ;
}
}
//rotor[t] = input;
t++;
}
} int crypto_number;
cin >> crypto_number;
//string *crypto = new string[crypto_number];
string crypto[];
t = ;
string input_crypto;
while( cin >> input_crypto && input_crypto != "" && t < crypto_number )
{
crypto[t] = input_crypto;
t++;
}
/*for ( int l = 0; l < t; l++ )
{
cout << crypto[l]<< endl;
}*/
//string *crypto_return = new string[crypto_number];
for ( int i = ; i < crypto_number; i++ )
{
for( int a = ; a < ; a++ )
{
for ( int b = ; b < strwide; b++ )
{
rotor_instead[a][b] = rotor[a][b];
}
}
//int second_rotor_count = 0;
//char *crypto_return = new char[crypto[i].size()];
char crypto_return[];
//cout << crypto[i].size() << endl;
for ( int j = ; j < crypto[i].size(); j++ )
{
for ( int r = ; r < strwide; r++ )
{
if ( rotor_instead[][r].second == crypto[i][j])
{
crypto_return[j] = rotor_instead[][r].first; for ( int k = ; k < strwide; k++ )
{
if ( rotor_instead[][k].second == crypto_return[j])
{
crypto_return[j] = rotor_instead[][k].first;
for ( int s = ; s < strwide; s++ )
{
if ( rotor_instead[][s].second == crypto_return[j] )
{
crypto_return[j] = rotor_instead[][s].first;
}
}
} }
} } for ( int d = ; d < strwide; d++ )
{
rotor_instead[][d].first += ;
rotor_instead[][d].second += ;
if (rotor_instead[][d].first == 'a'+ strwide )
{
rotor_instead[][d].first -= strwide;
}
if ( rotor_instead[][d].second == 'A'+strwide )
{
rotor_instead[][d].second -= strwide;
}
} if ( (j+)%strwide == )
{
//second_rotor_count++;
for ( int d = ; d < strwide; d++ )
{
rotor_instead[][d].first += ;
rotor_instead[][d].second += ;
if ( rotor_instead[][d].first == 'A'+strwide )
{
rotor_instead[][d].first -= strwide;
}
if ( rotor_instead[][d].second == 'A'+strwide )
{
rotor_instead[][d].second -= strwide;
}
}
} if ( (j + )%( strwide*strwide) == )
{
for ( int d = ; d < strwide; d++ )
{
rotor_instead[][d].first += ;
rotor_instead[][d].second += ;
if ( rotor_instead[][d].first == 'A'+strwide )
{
rotor_instead[][d].first -= strwide;
}
if ( rotor_instead[][d].second == 'A'+strwide )
{
rotor_instead[][d].second -= strwide;
}
}
} } /*for ( int a = 0; a < 3; a++ )
{
for ( int b = 0; b < strwide; b++ )
{
cout << rotor_instead[a][b].first <<" "<< rotor_instead[a][b].second << endl;
}
}*/
cout << "Enigma "<< i+ <<":"<< endl;
for ( int c = ; c < crypto[i].size(); c++ )
{
cout << crypto_return[c];
}
cout << endl;
if ( i != crypto_number - )
{
cout << endl;
} } return ;
}

ACM/ICPC ZOJ1009-Enigma 解题代码的更多相关文章

  1. ACM/ICPC ZOJ1003-Crashing Balloon 解题代码

    #include <iostream> using namespace std; int main() { int **array = new int *[100]; for ( int ...

  2. UVa 1225 - Digit Counting - ACM/ICPC Danang 2007 解题报告 - C语言

    1.题目大意 把前n$(n\le 10000)$个整数顺次写在一起:12345678910111213……计算0~9各出现了多少次. 2.思路 第一想法是打表,然而觉得稍微有点暴力.不过暂时没有想到更 ...

  3. UVa 1585 - Score - ACM/ICPC Seoul 2005 解题报告 - C语言

    1.题目大意 给出一个由O和X组成的字符串(长度为80以内),每个O的得分为目前连续出现的O的数量,X得分为0,统计得分. 2.思路 实在说不出了,这题没过脑AC的.直接贴代码吧.=_= 3.代码 # ...

  4. 【转】lonekight@xmu·ACM/ICPC 回忆录

    转自:http://hi.baidu.com/ordeder/item/2a342a7fe7cb9e336dc37c89 2009年09月06日 星期日 21:55 初识ACM最早听说ACM/ICPC ...

  5. hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...

  6. 2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)

    摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5 ...

  7. ACM/ICPC 之 BFS(离线)+康拓展开(TSH OJ-玩具(Toy))

    祝大家新年快乐,相信在新的一年里一定有我们自己的梦! 这是一个简化的魔板问题,只需输出步骤即可. 玩具(Toy) 描述 ZC神最擅长逻辑推理,一日,他给大家讲述起自己儿时的数字玩具. 该玩具酷似魔方, ...

  8. hduoj 4710 Balls Rearrangement 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4710 Balls Rearrangement Time Limit: 6000/3000 MS (Java/Ot ...

  9. 【转】ACM/ICPC生涯总结暨退役宣言—alpc55

    转自:http://hi.baidu.com/accplaystation/item/ca4c2ec565fa0b7fced4f811 ACM/ICPC生涯总结暨退役宣言—alpc55 前言 早就该写 ...

  10. hduoj 4708 Rotation Lock Puzzle 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4708 Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/O ...

随机推荐

  1. nginx错误汇总

    一.Nginx出现413 Request Entity Too Large错误解决方法 Nginx出现的413 Request Entity Too Large错误,这个错误一般在上传文件的时候出现, ...

  2. 第K顺序统计量

    1.第K顺序统计量概念 在一个由n个元素组成的集合中,第k个顺序统计量是该集合中第k小的元素.例如,最小值是第1顺序统计量,最大值是第n顺序统计量. 2.求Top K元素与求第K顺序统计量不同 Top ...

  3. HDU 2817 A sequence of numbers

    http://acm.hdu.edu.cn/showproblem.php?pid=2817 __int64 pow_mod (__int64 a, __int64 n, __int64 m)快速幂取 ...

  4. jQuery掷骰子

    网上找的jQuery掷骰子效果,测试兼容IE7及以上浏览器,IE6没有测试 js代码如下: $(function(){ var dice = $("#dice"); dice.cl ...

  5. linux中cron用法

    http://blog.chinaunix.net/uid-677314-id-83387.html

  6. linux 内存管理——内核的shmall 和shmmax 参数

    内核的 shmall 和 shmmax 参数 SHMMAX= 配置了最大的内存segment的大小 ------>这个设置的比SGA_MAX_SIZE大比较好. SHMMIN= 最小的内存seg ...

  7. Spark Pipe使用方法(外部程序调用方法)

    写在前面: 1.我们使用的是Hadoop2.2.0,Spark 1.0. 2.这里使用的样例是经典的求pai程序来演示这个开发过程. 3.我们暂时使用java程序来开发,按照需要后面改用scala来开 ...

  8. 整理收藏一份PHP高级工程师的笔试题

    整理了一份PHP高级工程师的笔试题,问题很全面.嗯,基本上这些题都答得不错,那么你应该可以胜任大部分互联网企业的PHP职位了.下面直接上题. 1. 基本知识点 HTTP协议中几个状态码的含义:503, ...

  9. Android音频底层调试-基于tinyalsa

    因为Android中默认并没有使用标准alsa,而是使用的是tinyalsa.所以就算基于命令行的測试也要使用libtinyalsa.Android系统在上层Audio千变万化的时候,能够能这些个工具 ...

  10. 四种方案解决ScrollView嵌套ListView问题

    在工作中,曾多次碰到ScrollView嵌套ListView的问题,网上的解决方法有很多种,但是杂而不全.我试过很多种方法,它们各有利弊. 在这里我将会从使用ScrollView嵌套ListView结 ...