Blame view

P33371_en/S001-AC.cc 388 Bytes
Imanol-Mikel Barba Sabariego authored
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
#include <iostream>
#include <iomanip>

using namespace std;

char encoded(char c, int k)
{
	if(c == '_')
	{
		return ' ';
	}
	else if(c > 96 && c < 123)
	{
		return ((c - 97 + k) % 26) + 65 ;
	}
	else
	{
		return c;
	}
}

int main()
{
	int k;
	char c;
	while(cin >> k)
	{
		cin >> c;
		while(c != '.')
		{
			cout << encoded(c,k);
			cin >> c;
		}
		cout << endl;
	}
        return 0;
}