代码如下:
#include<iostream.h>
#include<conio.h>
#include<string.h>
string encrypt(string& msg, string& alphabets, string& substitution){
string ct="";
for(int i=0;i<msg.length();i++){
for(int j=0;j<substitution.length();j++){
if(msg[i]==alphabets[j]){
ct+=substitution[j];
}
}
}
return ct;
}
string decrypt(string msg , string alphabets, string substitution){
string pt="";
for(int i=0;i<msg.length();i++){
for(int j=0;j<substitution.length();j++){
if(msg[i]==substitution[j]){
pt+=alphabets[j];
}
}
}
return pt;
}
int main()
{
clrscr();
string alphabetss="abcdefghijklmnopqrstuvwxyz";
string substitutionn="qwertyuiopasdfghjklzxcvbnm";
string msgg="absdhj";
string cipher=encrypt(msgg,alphabetss,substitutionn);
cout<<cipher<<endl;
string plain=decrypt(cipher,alphabetss,substitutionn);
cout<<plain;
getch();
return 0;
}
当我在 Turbo C++ 中运行时,第 5 行出现声明语法错误。 我明天有考试,我们只能使用 Turbo C++,请帮忙 错误消息: CPP 行:5 声明语法错误
附言当我在普通的 c++ 编译器中运行它时,我没有遇到任何问题,只有在 turbo c++ 中