fojtasd

Untitled

Dec 17th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     string megaslovo, slovo1, slovo2, slovo3;
  11.     int a = 0;
  12.     bool proof1 = true;
  13.  
  14.     cout << "Zadejte 3 slova:" << endl;
  15.     getline(cin, megaslovo);
  16.    
  17.     for (unsigned int i=0; i < megaslovo.length(); i++)
  18.     {
  19.  
  20.         if (megaslovo[i] == ' ' && proof1 == true)
  21.         {
  22.             slovo1 = megaslovo.substr(a,i);
  23.             megaslovo = megaslovo.replace(i, 1, "#");
  24.             a = i+1;
  25.             proof1 = false;
  26.         }  
  27.  
  28.         if (megaslovo[i] == ' ')
  29.         {
  30.             slovo2 = megaslovo.substr(a, i - slovo1.length() - 1);
  31.             slovo3 = megaslovo.substr((slovo1.length() + slovo2.length())+2, megaslovo.length());
  32.             a = i + 1;
  33.         }
  34.     }
  35.    
  36.  
  37.     if ((slovo1.length() < 1) || (slovo2.length() < 1) || (slovo3.length() < 1))
  38.     {
  39.         cout << "Nespravny vstup." << endl;
  40.         return 1;
  41.     }
  42.  
  43.  
  44.     for (unsigned int i = 0; i < slovo1.length(); i++)
  45.     {
  46.         if (slovo1[i] >= 'A' and slovo1[i] <= 'Z')
  47.         {
  48.             slovo1[i] = slovo1[i] + 32;
  49.         }
  50.     }
  51.  
  52.     for (unsigned int i = 0; i < slovo2.length(); i++)
  53.     {
  54.         if (slovo2[i] >= 'A' and slovo2[i] <= 'Z')
  55.         {
  56.             slovo2[i] = slovo2[i] + 32;
  57.         }
  58.     }
  59.  
  60.     for (unsigned int i = 0; i < slovo3.length(); i++)
  61.     {
  62.         if (slovo3[i] >= 'A' and slovo3[i] <= 'Z')
  63.         {
  64.             slovo3[i] = slovo3[i] + 32;
  65.         }
  66.     }
  67.  
  68.  
  69.     if ((slovo1) == (slovo2))
  70.     {
  71.         cout << "Slovo1 a slovo2 jsou stejna." << endl;
  72.     }
  73.     else cout << "Slovo1 a slovo2 nejsou stejna." << endl;
  74.  
  75.  
  76.     if ((slovo1) == (slovo3))
  77.     {
  78.         cout << "Slovo1 a slovo3 jsou stejna." << endl;
  79.     }
  80.     else cout << "Slovo1 a slovo3 nejsou stejna." << endl;
  81.  
  82.     if ((slovo2) == (slovo3))
  83.     {
  84.         cout << "Slovo2 a slovo3 jsou stejna." << endl;
  85.     }
  86.     else cout << "Slovo2 a slovo3 nejsou stejna." << endl;
  87.  
  88.     cout << "Pocet znaku ve slovo1 je: " << slovo1.length() << endl;
  89.     cout << "Pocet znaku ve slovo2 je: " << slovo2.length() << endl;
  90.     cout << "Pocet znaku ve slovo3 je: " << slovo3.length() << endl;
  91.  
  92.     return 0;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment