fork download
  1. #include <iostream>
  2. #include <cstring>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7. int k, dlugosc;
  8. string napis;
  9. cin >> k >> napis;
  10. dlugosc = napis.size();
  11. char tab[dlugosc+1];
  12. strcpy (tab, napis.c_str());
  13.  
  14.  
  15. for (int i = 0; i < dlugosc; i++) {
  16. cin >> tab[i];
  17. if (tab[i] >= 'a' && tab[i] <= 'z') {
  18. if ((tab[i]+k) > 'z')
  19. tab[i] = 'a' + ((tab[i]+k)-'z');
  20. else
  21. tab[i] += k;
  22.  
  23. cout << tab[i];
  24. }
  25. else if (tab[i] >= 'a' && tab[i] <= 'z') {
  26. if ((k>5 && (tab[i]+k)>'z') || (tab[i]+k)>'z')
  27. tab[i] = '`' + ((tab[i]+k)-'z');
  28. else
  29. tab[i] += k;
  30. cout << tab[i];
  31. }
  32. else
  33. cout << tab[i];
  34. }
  35. }
  36.  
  37.  
Success #stdin #stdout 0s 4488KB
stdin
Janek
stdout
Standard output is empty