Advertisement
Emanuele_Bruno

Esame 2

Dec 8th, 2015
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. const string S[]={"lamoremio",
  6.                   "aabbii",
  7.                   "sichiama",
  8.                   "ddeeoo",
  9.                   "rosaria"};
  10. const unsigned int RIG=5;
  11.  
  12. bool piuvocali(const string S[],const unsigned int RIG);
  13.  
  14. int main()
  15. {
  16.     cout <<"Se ci sono piu' vocali il risultato e' true, e il risultato e':"<<piuvocali(S,RIG);
  17.     return 0;
  18. }
  19.  
  20. bool piuvocali(const string S[],const unsigned int RIG)
  21. {
  22.     unsigned int i=1,k,vocali=0,lun_x;
  23.     string x;
  24.     while (i<RIG)
  25.     {
  26.         k=1;
  27.         while (k<S[i].length())
  28.         {
  29.             x+=S[i][k];
  30.             k+=2;
  31.         }
  32.         i+=2;
  33.     }
  34.     lun_x=x.length();
  35.     i=0;
  36.     while (i<lun_x)
  37.     {
  38.         switch(x[i])
  39.         {
  40.             case('a'): case('e'): case('i'): case('o'): case('u'): vocali++;
  41.         }
  42.         i++;
  43.     }// cout<<"\n"<<x<<"\n"; // da scommentare per debug
  44.     if ((lun_x-vocali)<vocali) return true;
  45.     else return false;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement