嗨,我正试图在c++中编写一个反向密码.我正在努力开始,可以使用一些指导
Hi, I am trying to write a reverse cipher code in C++. I am struggling to get started and could use some guidance?
密码应该接受用户输入的字符串,然后吐出加密后的代码。
所以如果字符串是ABCD,那么加密是ZYXW。
但是我正在努力弄清楚如何开始编写函数。我想使用一个函数,然后在主函数中调用它,当我需要它!谢谢。
#include<iostream>
using namespace std;
int main() {
char a[100];
cout<<"Enter A String :";
cin>>a;
//Your Function Calling Should Be this
//Supposing all characters are uppercase
int st = 65 , et = 90;
char b[100];
for(int i=0;a[i]!=' ';i++){
b[i] = et - (a[i] - 65);
}
cout<<"nYour Answer :"<<b;
return 0;
}
这将为您工作
你可以使用这个函数:
char convert(char c) {
return 'Z' - (c - 'A');
}
像这样使用:
std::transform(s.begin(), s.end(), s.begin(), convert);
s
是要转换的字符串。
相关文章:
- 努力将整数转换为链表。不知道我在这里做错了什么
- c++中的oop(密码生成)
- 密码登录程序将永远循环并显示不正确的结果
- OpenSSL没有共享密码
- Cryptopp:获取密码输入的填充字符串
- 密码长度验证 (c++)
- C++ win32 如何使密码字段可选并启用复制和粘贴?
- 仿射密码解密,输出大小写不同
- 替换密码:哪一个?
- ConstexPR :GCC比Clang更努力地评估ConstexPR
- 无法使用 openssl 服务器,因为密码已过时...什么的...ERR_SSL_VERSION_OR_CIPHER_MISMATCH
- 如何使用 c++ 在 sqlite3 中打开受密码保护的数据库?
- 我在解决此错误时遇到问题.我正在努力在主函数中传递数组
- 根据用户名和密码 Qt C++重新访问数据库值
- C++密码问题
- 无法在 Cocos2dx 中使用受密码保护的 zip 文件
- 如何使用librdkafka设置明文协议(无SASL)的用户名和密码?
- 如何将凯撒密码的元素从字符串更改为字符串
- 如何在C++的凯撒密码程序中包含空格?
- 嗨,我正试图在c++中编写一个反向密码.我正在努力开始,可以使用一些指导