encryption.cpp
来自「C++上机课的习题答案」· C++ 代码 · 共 48 行
CPP
48 行
// Chapter 5 of C++ How to Program
// Exercise2.cpp
// 加密解密,方法:对字符串中的每个字符按字符加上同样的整数值(例如5)
//变成ASCII码表中其它字符形成新的字符串,解密时减去相同的进行恢复。
#include <iostream>
using std::cout;
using std::endl;
/* Write the prototype for function encrypt(加密) */
/* Write the prototype for function decrypt (解密)*/
int main()
{
// create a string to encrypt
//把这里的字符数组改成字符指针,会出现什么情况,解释原因。
char string[] = "this is a secret!";
cout << "Original string is: " << string << endl;
encrypt( string );
cout << "Encrypted string is: " << string << endl;
decrypt( string );
cout << "Decrypted string is: " << string << endl;
system("PAUSE");
return 0;
} // end main
// encrypt data
void encrypt( char e[] )
{
/* Write implementation(实现) for function encrypt */
} // end function encrypt
// decrypt data
void decrypt( char *ePtr )
{
/* Write implementation for function decrypt */
} // end function decrypt
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?