-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path1036_Crypto_Columns.cpp
More file actions
47 lines (46 loc) · 1.17 KB
/
Copy path1036_Crypto_Columns.cpp
File metadata and controls
47 lines (46 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Problem#: 1036
// Submission#: 940069
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <iostream>
#include <string>
using namespace std;
string keyword;
string code;
char colum[101][101];
void judge ()
{
int length = keyword.length();
int codeleg = code.length();
int numcol = codeleg / length;
int count = 0;
for(int i = 'A';i <= 'Z';i ++)
{
for(int col = 0;col < length;col ++)
{
if(keyword[col] == i)
{
for(int j = 0;j < numcol;j ++)
{
colum[col][j] = code[count];
count ++;
}
}
}
}
for(int i = 0;i < numcol;i ++)
{
for(int j = 0;j < length;j ++ )
cout << colum[j][i];
}
cout << endl;
}
int main()
{
while (cin >> keyword && keyword != "THEEND")
{
cin >> code;
judge();
}
}