fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. string jawny, szyfrogram = "";
  8. int klucz, dl;
  9.  
  10. cout << "Podaj tekst jawny (bez spacji): ";
  11. cin >> jawny;
  12. cout << "Podaj klucz szyfrowania: ";
  13. cin >> klucz;
  14.  
  15. dl = jawny.length();
  16.  
  17. for (int i = 0; i < klucz; i++) {
  18. for (int j = i; j < dl; j = j + klucz) {
  19. szyfrogram += jawny[j];
  20. }
  21. }
  22.  
  23. cout << "\nSzyfrogram: " << szyfrogram << endl;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 5316KB
stdin
PRZYNIESPRZESYLKEDOPARKU
4
stdout
Podaj tekst jawny (bez spacji): Podaj klucz szyfrowania: 
Szyfrogram: PNPSEARIRYDRZEZLOKYSEKPU