恺撒加密
#include<iostream>using namespace std;
char a,b,c;
int main()
{
cin>>a>>b>>c;
int d;
d=a;
int e;
e=b;
int f;
f=c;
cout<<char(d+1)<<char(e+1)<<char(f+1)<<endl;
return 0;
}
怎么将这个程序改一下,使输入x y z变成y z a
char caesar_cipher( char c ) { return 'a' + (c-'a'+1)%26; } #include <iostream> using namespace std; int main( void ) { char a,b,c; cin >> a >> b >> c; cout << caesar_cipher(a) << caesar_cipher(b) << caesar_cipher(c) << endl; return 0; }
char caesar_cipher( char c ) { if( c>='A' && c<='Z' ) return 'A' + (c-'A'+1)%26; if( c>='a' && c<='z' ) return 'a' + (c-'a'+1)%26; return c; } #include <iostream> using namespace std; int main( void ) { char a,b,c; if( cin>>a>>b>>c ) cout << caesar_cipher(a) << caesar_cipher(b) << caesar_cipher(c) << endl; return 0; }