fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. string jawny, szyfrogram = "";
  7. int dl, klucz;
  8. char kod;
  9.  
  10. cout << "Podaj slowo: "; cin >> jawny;
  11. dl = jawny.length();
  12.  
  13. cout << "Podaj klucz: "; cin >> klucz;
  14.  
  15. for (int i=0; i<dl; i++)
  16. {
  17. kod = jawny [i] + klucz;
  18. if (kod > 'Z')
  19. kod= kod - 26;
  20. szyfrogram = szyfrogram + kod;
  21. }
  22.  
  23. cout << szyfrogram << endl;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5320KB
stdin
BALETNICA
12
stdout
Podaj slowo: Podaj klucz: NMXQFZUOM