Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. using namespace std;
  5.  
  6. void LlegirParaules(vector<string>& cas, string& paraula) {
  7. while (paraula != "FI") {
  8. cas.push_back(paraula);
  9. cin >> paraula;
  10. }
  11. }
  12.  
  13. int count_vocal(string p){
  14.  
  15. int count = 0;
  16. for(int i = 0; i < p.length();i++){
  17. char c = p[i];
  18. if (c == 'A' or c == 'E' or c=='I' or c == 'O' or c=='U') count++;
  19. }
  20. return count;
  21. }
  22.  
  23. int main(){
  24. string palabra;
  25. while(cin >> palabra){
  26. if(palabra == "FI") cout << "-" << endl;
  27. else{
  28. vector<string>s;
  29. bool hay = false;
  30. LlegirParaules(s,palabra);
  31.  
  32. /*for(int i = 0; i < s.size()-1; i++){
  33. if (count_vocal(s[i]) == count_vocal(s[s.size()-1])){
  34. cout << s[i] << ", " << i << endl;
  35. hay = true;
  36. }*/
  37. int i = 0;
  38. while(i< s.size()-1 and not hay){
  39. if (count_vocal(s[i]) == count_vocal(s[s.size()-1])){
  40. cout << s[i] << ", " << i << endl;
  41. hay = true;
  42.  
  43. }
  44. i++;
  45. }
  46. if(not hay) cout << "-" << endl;
  47.  
  48. }
  49.  
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement