我对C++非常新颖而且可怕。 我希望有人能够弄清楚这个错误的含义,我真的不知道该怎么做,我不是要求你让它变得更有活力,我意识到我的尴尬。C++简单的数字加密字母
我想把字母转换成数字,我知道这是弱加密。
代码:
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
std::string ptxt = "";
string etxt = "";
cin >> ptxt;
std::replace(ptxt.begin(), ptxt.end(), 'a', '1');
std::replace(ptxt.begin(), ptxt.end(), 'b', '2');
std::replace(ptxt.begin(), ptxt.end(), 'c', '3');
std::replace(ptxt.begin(), ptxt.end(), 'd', '4');
std::replace(ptxt.begin(), ptxt.end(), 'e', '5');
std::replace(ptxt.begin(), ptxt.end(), 'f', '6');
std::replace(ptxt.begin(), ptxt.end(), 'g', '7');
std::replace(ptxt.begin(), ptxt.end(), 'h', '8');
std::replace(ptxt.begin(), ptxt.end(), 'i', '9');
std::replace(ptxt.begin(), ptxt.end(), 'j', '10');
std::replace(ptxt.begin(), ptxt.end(), 'k', '11');
std::replace(ptxt.begin(), ptxt.end(), 'l', '12');
std::replace(ptxt.begin(), ptxt.end(), 'm', '13');
std::replace(ptxt.begin(), ptxt.end(), 'n', '14');
std::replace(ptxt.begin(), ptxt.end(), 'o', '15');
std::replace(ptxt.begin(), ptxt.end(), 'p', '16');
std::replace(ptxt.begin(), ptxt.end(), 'q', '17');
std::replace(ptxt.begin(), ptxt.end(), 'r', '18');
std::replace(ptxt.begin(), ptxt.end(), 's', '19');
std::replace(ptxt.begin(), ptxt.end(), 't', '20');
std::replace(ptxt.begin(), ptxt.end(), 'u', '21');
std::replace(ptxt.begin(), ptxt.end(), 'v', '22');
std::replace(ptxt.begin(), ptxt.end(), 'w', '23');
std::replace(ptxt.begin(), ptxt.end(), 'x', '24');
std::replace(ptxt.begin(), ptxt.end(), 'y', '25');
std::replace(ptxt.begin(), ptxt.end(), 'z', '26');
return 0;
}
您需要查看警告。 – 2014-11-06 01:55:45
你有没有读错误? ''10'不是单个字符。 – user657267 2014-11-06 01:56:33
看起来很古怪,哇! – 2014-11-06 01:58:30