C++编程问题,帮忙纠错,谢谢

来源:百度知道 编辑:UC知道 时间:2024/06/17 19:41:20
#include<string>
#include <iostream>
using namespace std;
void txt(string trans);
void ascii(string s);
string code(string message, int n);

int main()
{
char s='y';
while (s=='y' || s=='Y')
{
txt();
cout<<"Do you want to continue or not?(Y/N)"<<endl;
cin>>s;
}
return 0;
}

void txt()
{
string h, trans;
int coding=0;
cout<<"Pleaase input the text that you want to transfer."<<endl;
cin>>h;
getline(cin,h);
cout<<"Please input coding."<<endl;
cin>>coding;
trans=code(h,coding);
cout<<"The transfered message is: "<<trans<<endl;
void ascii(string trans);
}

string code(string h, int coding)
{
int len,i;
char c;
string trans;
len=h.le

做加密函数?
string code(string h, int coding)
{
int len,i;
char c;
string trans;
len=h.length();
for (i=0;i<=len;i++)
{
c=h.at(i);
if ( 'a' <= c && c <= 'z')
{
c += coding;
if ( c > 'z' )
trans += char(c-26);
else
trans += c;
}
if ( '0' <= c && c <= '9' )
{
c += coding;
if ( c > '9' )
trans += char(c-10);
else
trans += c;
}
if ( 'A' <= c && c <= 'Z' )
{
c += coding;
if ( c > 'Z' )
trans += char(c-26);
else
trans += c;
}
else
{trans+=c;}
}
return trans;
}

ascii函数是要专程01字符串?