fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool czySamogloska(char c) {
  5. c = tolower(c);
  6. return (c == 'a') || (c == 'e') || (c == 'i') || (c == 'o') || (c == 'u') || (c == 'y');
  7. }
  8.  
  9. unsigned int liczSamogloski(std::string str) {
  10. unsigned int samogloski = 0;
  11.  
  12. for (char& c: str) {
  13. if (czySamogloska(c)) {
  14. samogloski++;
  15. }
  16. }
  17.  
  18. return samogloski;
  19. }
  20.  
  21. int main() {
  22. std::cout << liczSamogloski("hello") << std::endl;
  23. std::cout << liczSamogloski("world") << std::endl;
  24. std::cout << liczSamogloski("PATRYK") << std::endl;
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
2
1
2