【算法】模拟
#include<cstdio> #include<cstring> const int maxm=1010; char sm[maxm],key[maxm],s[maxm]; int len,lenk; bool isbig(char c) {return c>='A'&&c<='Z';} int main() { scanf("%s",key);scanf("%s",sm); len=strlen(sm);lenk=strlen(key); for(int i=lenk;i<len;i++)key[i]=key[i%lenk]; for(int i=0;i<len;i++) { int a=isbig(sm[i])?sm[i]-'A':sm[i]-'a'; int b=isbig(key[i])?key[i]-'A':key[i]-'a'; if(a<b)a+=26; s[i]=isbig(sm[i])?(a-b)+'A':(a-b)+'a'; } printf("%s",s); return 0; }