-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencriptado.cpp
More file actions
49 lines (43 loc) · 921 Bytes
/
encriptado.cpp
File metadata and controls
49 lines (43 loc) · 921 Bytes
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
//TIEMPO: 37:22
#include <bits/stdc++.h>
using namespace std;
#define MAX 5000
vector<int> num;
int main(){
ifstream fin("in.txt");
ifstream finn("in.txt");
string linea;
int n,m,l,largo=0;
fin >> n >> m;
getline(finn,linea);
getline(finn,linea);
char a;
while(m>=10){
num.push_back(m%10);
m/=10;
largo++;
}
largo++;
num.push_back(m);
if(largo<n){
for(int i=largo;i<n;i++){
num.push_back(0);
}
}
reverse(num.begin(),num.end());
l=0;
for(int i=0;i<linea.size();i++){
a=linea[i];
if(l==num.size()){
l=0;
}
if(a!=' '){
if(int(a)+num[l] > int('Z')){
cout << char( int('A')+((num[l]-1)-abs(int(a)-int('Z'))) );
} else {
cout << char( int(a)+num[l] );
}
l++;
}
}
}