-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathcaesar-cipher.cpp
More file actions
48 lines (46 loc) · 955 Bytes
/
caesar-cipher.cpp
File metadata and controls
48 lines (46 loc) · 955 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
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n;
cin >> n;
string s;
cin >> s;
int k;
cin >> k;
int charCase=0; //0-Lower
for(int i=0;i<s.size();i++)
{
char c=(char)s[i];
if((s[i]>='a' && s[i]<='z') || (s[i]>='A' && s[i]<='Z'))
{
if((s[i]>='a' && s[i]<='z'))
{
charCase=0;
}
else if((s[i]>='A' && s[i]<='Z'))
{
charCase=1;
}
for(int m=0;m<k;m++)
{
c++;
if(charCase==1)
{
if(c>90)
c=65;
}
else
{
if(c>122)
c=97;
}
}
}
cout<<c;
}
return 0;
}