我對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