fork download
  1. #include <iostream>
  2. #include <stdio.h>
  3. using namespace std;
  4. int tab[27][27];
  5. string wyraz,klucz;
  6. int d,e,ile;
  7. int main()
  8. {
  9. for(int i=1; i<=26; i++)
  10. {
  11. for(int j=1; j<=26; j++)
  12. {
  13. if(j+64+i-1>90)
  14. {
  15. tab[i][j]=(j+64+i-1-26);
  16. }
  17. else
  18. {
  19. tab[i][j]=(j+64+i-1);
  20. }
  21. }
  22. }
  23. cin>>ile;
  24. //
  25. while(ile--)
  26. {
  27. //
  28. cin>>klucz;
  29. getline(cin, wyraz);//
  30. getline(cin, wyraz);
  31. d=wyraz.length();
  32. e=klucz.length();
  33. int i=0;
  34. int j=0;
  35. while(i<d)
  36. {
  37. for(int j=0; j<e; j++)
  38. {
  39. if(wyraz[i]==' ')
  40. {
  41. wyraz[i]=' ';
  42. i++;
  43. }
  44. wyraz[i]=(char)tab[(int)wyraz[i]-64][(int)klucz[j]-64];
  45. i++;
  46. }
  47. j=0;
  48. }
  49. cout<<wyraz;
  50. if (ile!=0) cout<<endl;
  51. }
  52. return 0;
  53. }
  54.  
Runtime error #stdin #stdout 0s 3464KB
stdin
3
KOT
ALA MA KOTA
TOK
BOLEK I LOLEK
RAK
SZYFROWANIE
stdout
KZT WO DYHT