Description
To translate a string of text into a password, the law of the password is: the original lowercase letters are all translated into uppercase letters, all uppercase letters are translated into lowercase, the number of translation rules are as follows:
0-->9
1-->8
2-->7
3-->6
4-->5
5-->4
6-->3
7-->2
8-->1
9-->0
The order of all characters is then reversed.
Input
Enter a string of text with a maximum number of characters not exceeding 100.
Output
The result of the output encoding.
Sample Input
China
Sample Output
Anihc
Code
#include <iostream> using namespace std; int main () { char a[100]; int i=0; while (Cin>>a[i]) { if (a[i]>= ' a ' &&a[i]<= ' z ') a[i]=a[i]-32; else if (a[i]>= ' a ' &&a[i]<= ' Z ') a[i]=a[i]+32; else if (a[i]== ' 0 ') a[i]= ' 9 '; else if (a[i]== ' 1 ') a[i]= ' 8 '; else if (a[i]== ' 2 ') a[i]= ' 7 '; else if (a[i]== ' 3 ') a[i]= ' 6 '; else if (a[i]== ' 4 ') a[i]= ' 5 '; else if (a[i]== ' 5 ') a[i]= ' 4 '; else if (a[i]== ' 6 ') a[i]= ' 3 '; else if (a[i]== ' 7 ') a[i]= ' 2 '; else if (a[i]== ' 8 ') a[i]= ' 1 '; else if (a[i]== ' 9 ') a[i]= ' 0 '; i++; } for (int n=i-1;n>=0;n--) cout<<a[n]; return 0; }
Some projects--simple coding