-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencode.cpp
More file actions
51 lines (43 loc) · 1.03 KB
/
encode.cpp
File metadata and controls
51 lines (43 loc) · 1.03 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
48
49
50
51
#include "permutation.h"
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
typedef long long int64;
using namespace std;
int main() {
freopen("text.txt", "rb", stdin);
fstream f1("decoder.txt", fstream::in);
fstream f2("poetry.txt", fstream::in);
freopen("encoded.txt", "wt", stdout);
string str;
string s;
while (getline(f1, s))
str += s;
vector<int> a = get_permutation(str);
vector<string> b;
for (int i = 0; i < 256; ++i) {
getline(f2, s);
b.pb(s);
}
char ch;
int i = 0;
while (true) {
int x = getchar();
if (x == EOF)
break;
ch = x;
cout << b[a[((ch + i) % 256 + 256) % 256]] << endl;
++i;
}
return 0;
}