-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy path10222.cpp
More file actions
executable file
·33 lines (29 loc) · 867 Bytes
/
10222.cpp
File metadata and controls
executable file
·33 lines (29 loc) · 867 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
/* Problem: Decode the Mad man UVa 10222
Programmer: Md. Mahmud Ahsan
Compiled: Visual C++ 6.0
Date: 07-08-04
*/
#include <iostream>
using namespace std;
int main(){
/* store the code special rules [ \\ \' ] */
char string[] = "`1234567890-=qwertyuiop[]\\asdfghjkl;\'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:\"ZXCVBNM<>?";
char input[10000];
int i, j;
int flag;
while (cin.getline(input, sizeof(input))){
for (i = 0; input[i] != '\0'; i++){
flag = 0; //check input character is found int the string code
for (j = 0; string[j] != '\0'; j++){
if (input[i] == string[j]){
cout << string[j-2]; // print the previous - 1 character
flag = 1; // ensure that input character is found in the code
break;
}
}
if (flag == 0) cout << input[i];
}
cout << endl;
}
return 0;
}