返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.     string str;
  8.     cout<<"請輸入一字串: ";
  9.     getline(cin,str);
  10.     cout<<"加密後: "<<endl;
  11.     for(int i=0; i<str.length(); i++)
  12.         cout<<char(int(str[i])+2);
  13.     cout<<endl<<endl;
  14.     cout<<"請輸入一字串: ";
  15.     getline(cin,str);
  16.     cout<<"解密後: "<<endl;
  17.     for(int i=0; i<str.length(); i++)
  18.         cout<<char(int(str[i])-2);
  19.     cout<<endl<<endl;
  20.     system("pause");
  21.     return 0;   
  22. }
複製代碼

TOP

返回列表