- #include<iostream>
- #include<cstdlib>
- #include<string>
- using namespace std;
- int main()
- {
- string str;
- cout<<"請輸入一字串: ";
- getline(cin,str);
- cout<<"加密後: "<<endl;
- for(int i=0; i<str.length(); i++)
- cout<<char(int(str[i])+2);
- cout<<endl<<endl;
- cout<<"請輸入一字串: ";
- getline(cin,str);
- cout<<"解密後: "<<endl;
- for(int i=0; i<str.length(); i++)
- cout<<char(int(str[i])-2);
- cout<<endl<<endl;
- system("pause");
- return 0;
- }
複製代碼 |