Advertisement
zeushere

vowels

Apr 18th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <time.h>
  4. #include <math.h>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. int main(){
  10. srand(time(0));
  11. //W dowolnym ciągu znaku policz samogłoski (angielskie małe)
  12.  
  13.  
  14. char samo[7] = {'a','e','o','u','y','i','\0'};
  15.  
  16. string napis="Kacper i Magda";
  17. int roz=napis.size();
  18. int ilosc=0;
  19. int miejsce=0;
  20.  
  21. for(int i=0;i<=5;i++)
  22. {
  23.  
  24.     if(napis.find(samo[i])==string::npos)
  25.     {
  26.         cout<<"W tym wyrazie nie ma samogloski "<<samo[i]<<" "<<endl;
  27.     }
  28.  
  29.     if(miejsce = napis.find(samo[i])!=string::npos){
  30.     ilosc++;}
  31.     miejsce=napis.find(samo[i]);
  32. for (int j=1;j<=roz;j++){
  33.     if(napis.find(samo[i],miejsce+1)!=string::npos)
  34. {
  35. ilosc++;
  36. miejsce=napis.find(samo[i],miejsce+1);
  37.  
  38. }
  39. }
  40. }
  41. cout<<"Ten tekst ma "<<ilosc<<" samoglosek";
  42.  
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement