Advertisement
Guest User

Untitled

a guest
Oct 21st, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.  
  9.  
  10.     cout << "Program oblicza ilosc samoglosek i spolglosek w zdaniu" << endl;
  11.     cout << "Podaj zdanie: ";
  12.  
  13.     string zdanie = "";
  14.     getline(cin, zdanie);
  15.     transform(zdanie.begin(), zdanie.end(), zdanie.begin(), ::tolower);
  16.  
  17.     int d = zdanie.length();
  18.  
  19.     int ilosc_samoglosek = 0, ilosc_spolglosek = 0;
  20.  
  21.     for (int i=0; i<d; i++) {
  22.         if  ((zdanie[i] == 'a') ||
  23.             (zdanie[i] == 'e') ||
  24.             (zdanie[i] == 'y') ||
  25.             (zdanie[i] == 'i') ||
  26.             (zdanie[i] == 'o') ||
  27.             (zdanie[i] == 'ฤ…') ||
  28.             (zdanie[i] == 'ฤ™') ||
  29.             (zdanie[i] == 'u') ||
  30.             (zdanie[i] == 'รณ'))
  31.         ilosc_samoglosek++;
  32.         else if (zdanie[i] != ' ') ilosc_spolglosek++;
  33.     }
  34.  
  35.     cout << "Ilosc samoglosek w zdaniu: " << ilosc_samoglosek << endl;
  36.     cout << "Ilosc spolglosek w zdaniu: " << ilosc_spolglosek;
  37.  
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement