-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy path0021.cpp
More file actions
32 lines (30 loc) · 750 Bytes
/
0021.cpp
File metadata and controls
32 lines (30 loc) · 750 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
// 0021.简单密码破解
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
string s;
string mp[10] = {"0", "1", "abc","def","ghi", "jkl","mno", "pqrs", "tuv", "wxyz"};
while(getline(cin, s))
{
for(int i = 0; i < s.size(); i++)
{
int c = s[i];
if (isupper(s[i])) {
c = s[i]-'A'+1+'a';
if(c > 'z') c = 'a';
} else if (islower(s[i])) {
for(int j = 2; j < 10; j++)
{
if(mp[j].find(s[i]) != mp[j].npos)
{
c = j + '0';
}
}
}
printf("%c", c);
}
}
return 0;
}