文章
40
粉丝
607
获赞
68
访问
422.1k
#include<iostream>
#include<string>
#include<cstring>
#include<bitset>
using namespace std;
string miwen(string s) {
for (int i = 0;i < s.size();i++) {
if (s[i] >= 'a' && s[i] <= 'z')
{
s[i] = (s[i] - 97 + 2) % 26 + 97;
}
else if (s[i] >= 'A' && s[i] <= 'Z') {
s[i] = (s[i] - 65 + 2) % 26 + 65;
}
}
return s;
}
void f(string s) {
for (int i = 0;i < s.size();i++) {
bitset<8> bit = s[i];
if (bit.count() % 2 == 0) {
bit.set(7);
}
cout << s[i] << " " << bit.to_string() << " " << bit.to_ulong() << endl;
}
}
int main() {
string s;
while (cin >> s) {
cout << "原文:" << s << endl;
s = miwen(s);
cout << "密文:" << s << endl;
f(s);
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发