fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. int main() {
  7. int t, m1[30];
  8. char m[30], s[105];
  9. scanf("%d%s", &t, m);
  10. for(int i=0; i<strlen(m); i++) m1[i]=m[i]-'a';
  11. for(int i=0; i<t; i++) {
  12. scanf("%s", s);
  13. for(int j=0; j<strlen(s); j++) {
  14. if(s[j]>='A' && s[j]<='Z') {
  15. printf("%c", m1[s[j]-65]+65);
  16. }
  17. else if(s[j]>='a' && s[j]<='z') {
  18. printf("%c", m1[s[j]-97]+97);
  19. }
  20. else if(s[j]=='_') printf(" ");
  21. else printf("%c", s[j]);
  22. }
  23. printf("\n");
  24. }
  25. return 0;
  26. }
Success #stdin #stdout 0s 3300KB
stdin
5 qwertyuiopasdfghjklzxcvbnm
Ph
Pcssi
Bpke_kdc_epclc_jcijsc_mihyo?
Epcf_kdc_liswhyo_EIED_hy_Vimcvpcn_Zkdvp_siyo_viyecle.
Ipp!
stdout
Hi
Hello
What are these people doing?
They are solving TOTR in Codechef March long contest.
Ohh!