-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexchange.cpp
More file actions
43 lines (38 loc) · 814 Bytes
/
exchange.cpp
File metadata and controls
43 lines (38 loc) · 814 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
#include <iostream>
#include <string>
using namespace std;
void exchange(string s)
{
for (int i = 0; i < s.size(); i++)
{
if (isalpha(s[i]))
{
if (isupper(s[i])) cout << (char)tolower(s[i]);
else cout << (char)toupper(s[i]);
}
else if (isdigit(s[i]))
{
if (s[i] == '1') cout << (char)'O';
else if (s[i] == '2' || s[i] == '3') cout << (char)'T';
else if (s[i] == '4' || s[i] == '5') cout << (char)'F';
else if (s[i] == '6' || s[i] == '7') cout << (char)'S';
else if (s[i] == '8') cout << (char)'E';
else if (s[i] == '9') cout << (char)'N';
else cout << (char)'Z';
}
else
{
cout << s[i];
}
}
cout << endl;
}
int main()
{
string line;
while (getline(cin, line))
{
exchange(line);
}
return 0;
}