This article illustrates the way C + + implements the translation of simple passwords back to the original text. Share to everyone for your reference, specific as follows:
*
* Author: Liu Tongbin
* Date of Completion: November 28, 2012
* Version number: v1.0
* Input Description:
* Problem Description: There is a line of messages, has been translated into the code according to the following rules:
* a-->z A- ->z
* b-->y b-->y *
c-->x c-->x
* That is, the first letter becomes the 26th letter, the letter I letters into the letter (26-i+1), not the letter characters unchanged
* request that the password be translated back to the original.
* Program output:
* Problem Analysis: slightly
* Algorithm design: Slightly * *
#include <iostream>
using namespace std;
int main ()
{
int j,n;
Char ch[80];
cout<< "Input cipher Code:";
Gets (CH);
cout<< "Cipher Code:" <<ch<<endl;
j=0;
while (ch[j]!= ' ")
{
if (ch[j]>= ' A ') && (ch[j]<= ' Z '))
{
ch[j]=155-ch[j];
}
else if ((ch[j]>= ' a ') && (ch[j]<= ' z '))
{
ch[j]=219-ch[j];
}
else
{
ch[j]=ch[j];
}
j + +;
}
N=j;
cout<< "Original text:";
for (j=0;j<n;j++)
{
cout<<ch[j];
}
cout<<endl;
return 0;
}
The screenshot of the running effect is as follows:
I hope this article will help you with your C + + program design.