Created
June 16, 2015 01:15
-
-
Save KaterineM/b604350423b0e76d057a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <fstream> | |
#include <stdlib.h> | |
using namespace std; | |
int Largo(string palabra); | |
int cuantasVocales(string palabra, int n); | |
int main(){ | |
string palabra, a1[0], a2[0]; | |
int n, cuantas = 0; | |
ifstream texto1; | |
ifstream texto2; | |
texto1.open("texto3.txt"); | |
texto2.open("texto2.txt"); | |
if(texto1.fail() && texto2.fail()){ | |
cout << "El archivo no existe."; | |
system("PAUSE"); | |
exit (1); | |
} | |
else{ | |
while(texto1 >> palabra){ | |
n = Largo(palabra); | |
if(cuantasVocales(palabra, n) >= cuantas){ | |
cuantas = cuantasVocales(palabra, n); | |
a1[0] = palabra; | |
} | |
} | |
cout << "La palabra con mas vocales es " << palabra << endl; | |
} | |
texto1.close(); | |
texto2.close(); | |
return 0; | |
} | |
int Largo(string palabra){ | |
int largo = palabra.length(); | |
return largo; | |
} | |
int cuantasVocales(string palabra, int n){ | |
int i, cont = 0; | |
for(i=0;i<n-1;i++){ | |
if(palabra[i] == 'a' || palabra[i] == 'e' || palabra[i] == 'i' || palabra[i] == 'o' || palabra[i] == 'u'){ | |
cout << palabra[i] << endl; | |
cont++; | |
} | |
} | |
return cont; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment