Advertisement
dykow

Untitled

Nov 29th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. //string ala = "Ala ma kota, kot ma AlΔ™", text1 = "", text2 = "";
  9. //int len = ala.length();
  10.  
  11. int main()
  12. {/*
  13.     srand(time(NULL));
  14.  
  15.     int r = rand() / (RAND_MAX / len);
  16.    
  17.     for (int i = 0; i < r; i++)
  18.     {
  19.       text1 += ala[i];
  20.     }
  21.  
  22.     for (int i = r; i < len; i++)
  23.     {
  24.       text2 += ala[i];
  25.     }    
  26.        
  27.     cout << "Podtekst 1: " << text1 << "\n";
  28.     cout << "Podtekst 2: " << text2;*/
  29.    
  30.    
  31.     char k = 0;
  32.     cin >> k;
  33.    
  34.     string ala = "Ala ma kota, kot ma AlΔ™";
  35.    
  36.     string change = "";
  37.     cin >> change;
  38.    
  39.     size_t len = ala.length();
  40.     /*string fresh = "";
  41.    
  42.    
  43.     for (int i = 0; i < len; i++)
  44.     {
  45.       if (ala[i] != k)
  46.         fresh += ala[i];
  47.       else
  48.         fresh += change;
  49.     }
  50.    
  51.     cout << fresh;*/
  52.    
  53.     for (size_t i = 0; i < len; i++)
  54.     {
  55.       if (ala[i] == k)
  56.       {
  57.         ala[i] -= ala[i];
  58.         ala.insert(i, change);
  59.       }
  60.     }
  61.    
  62.     cout << ala;
  63.    
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement