Advertisement
Guest User

Code Idea Task 2

a guest
Dec 12th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main() {
  6. char str[20];
  7. char str2[20];
  8.  
  9. int idx1 = 0; // index for str array
  10. int idx2 = 0; // index for str2 array
  11.  
  12. // read the input
  13. cin.getline(str, 20); // <--- Vuvedi mu "I am a string"
  14.  
  15. int str_len = strlen(str);
  16.  
  17. int M = 4;
  18. int L = 3;
  19.  
  20. idx2 = 3; // Tova trqbva da si go izchislish tochno kolko trqbva da e
  21. for (int i = 0; i < str_len; i++) {
  22. if (idx2 == str_len) {
  23. idx2 = 0;
  24. }
  25.  
  26. str2[idx2] = str[i];
  27. idx2++;
  28. }
  29.  
  30. for (int i = 0; i < str_len; i++) {
  31. cout << (char) (str2[i] + M);
  32. }
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement