我正在做一个加密程序,我的教授告诉我这个程序是正确的,但是我在switch
语句中的逻辑是错误的,因为我是一个一个输入加密值..我的教授要我先把它放在一个变量中然后显示在加密值上..请帮帮我..
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<windows.h>
#include<cstdlib>
main()
{
const char *stringlength;
char input[100];
int i;
cout<<"Input letters only:";
cin>>input;
stringlength=input;
cout<<"\nEncryption Value:";
for(i=0; i<strlen(stringlength); i++)
{
switch(input[i])
{
case 'a':cout<<"0";break;
case 'A':cout<<"1";break;
case 'e':cout<<"2";break;
case 'E':cout<<"3";break;
case 'i':cout<<"4";break;
case 'I':cout<<"5";break;
case 'o':cout<<"6";break;
case 'O':cout<<"7";break;
case 'u':cout<<"8";break;
case 'U':cout<<"9";break;
case 'B':cout<<"C";break;
case 'C':cout<<"D";break;
case 'D':cout<<"E";break;
case 'F':cout<<"G";break;
case 'G':cout<<"H";break;
case 'H':cout<<"I";break;
case 'J':cout<<"K";break;
case 'K':cout<<"L";break;
case 'L':cout<<"M";break;
case 'M':cout<<"N";break;
case 'N':cout<<"O";break;
case 'P':cout<<"Q";break;
case 'Q':cout<<"R";break;
case 'R':cout<<"S";break;
case 'S':cout<<"T";break;
case 'T':cout<<"U";break;
case 'V':cout<<"W";break;
case 'W':cout<<"X";break;
case 'X':cout<<"Y";break;
case 'Y':cout<<"Z";break;
case 'Z':cout<<"A";break;
case 'b':cout<<"c";break;
case 'c':cout<<"d";break;
case 'd':cout<<"e";break;
case 'f':cout<<"g";break;
case 'g':cout<<"h";break;
case 'h':cout<<"i";break;
case 'j':cout<<"k";break;
case 'k':cout<<"l";break;
case 'l':cout<<"m";break;
case 'm':cout<<"n";break;
case 'n':cout<<"o";break;
case 'p':cout<<"q";break;
case 'q':cout<<"r";break;
case 'r':cout<<"s";break;
case 's':cout<<"t";break;
case 't':cout<<"u";break;
case 'v':cout<<"w";break;
case 'w':cout<<"x";break;
case 'x':cout<<"y";break;
case 'y':cout<<"z";break;
case 'z':cout<<"a";break;
default : cout<<"\nInvalid Character!\n"; break;
}
}
getch();
return 0;
}
我能用它做什么?我的提示是我需要一个变量,我可以在其中放置文本的所有加密值,然后cout
一次全部放置。