#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. [转]ASP.NET MVC 入门2、项目的目录结构与核心的DLL

    我们新建一个ASP.NET MVC的Web Application后,默认的情况下,项目的目录结构如下: App_Data :这个目录跟我们一般的ASP.NET website是一样的,用于存放数据. ...

  2. [Andrew]Ext.Net常用布局(Border布局)

    @(Html.X().Window().Width(600).Height(400).Layout(LayoutType.Border) .Items(p => {     p.Add(Html ...

  3. Ubuntu 14.04 SSH + 远程登录xrdp

    1. 安装ssh 打开"终端窗口",输入"sudo apt-get install openssh-server"-->回车-->输入"y ...

  4. Windows下部署Git Server端

    解决方案一: (注意:如果英文阅读没太大障碍,直接到Bonobo官网看相关文档即可.) win7(windows server 2008应该也可以,没测试过)+ IIS7.5(win7自带的)+ Gi ...

  5. marvell笔试题(嵌入式软件)

    有幸去Marvell参加面试,由于其要求WCDMA/GSM之类的,我还特地恶补了下这方面的知识.后来坐了2个小时的地铁后,到达了Marvell.公司还蛮不错的,里面环境都还可以.我投了这家公司也是同学 ...

  6. c++面试常见160问

    1.在C++ 程序中调用被C 编译器编译后的函数,为什么要加extern "C"?答:首先,extern是C/C++语言中表明函数和全局变量作用范围的关键字,该关键字告诉编译器,其 ...

  7. leetcode—Populating Next Right Pointers in Each Node

    1.题目描述 Given a binary tree   struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLink ...

  8. Kooboo中怎么新增一个关联的Details 动态页面。

    Kooboo中怎么新增一个关联的Details 动态页面. 有几个要点: 1. Sub Page的Parent Page 必须是英文书写.如果是中文会出现找不到页面 500错误 2. 要在Page M ...

  9. 问题-[Delphi]通过Map文件查找内存地址出错代码所在行

     一 什么是MAP文件       什么是 MAP 文件?简单地讲, MAP 文件是程序的全局符号.源文件和代码行号信息的唯一的文本表示方法,它可以在任何地方.任何时候使用,不需要有额外的程序进行支持 ...

  10. 有关window.location 对象

    之前在有关location的使用就一种方式给他的href赋值使页面跳转.今天看项目中的代码看到了一个不一样的用法 window.location.href = 'http://' + document ...