Created
April 6, 2017 21:23
-
-
Save Reflej0/ecc299a60ffb201f44f4bbd69572e0f2 to your computer and use it in GitHub Desktop.
Algoritmo en C# para encontrar palabras en una frase con mas de 3 vocales.
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace ConsoleApplication1 | |
{ | |
class Frase | |
{ | |
public static int PalabrasVocales(string frase) | |
{ | |
frase.ToLower(); | |
string[] palabras = frase.Split(new Char[] {' '}); | |
int vocales = 0; | |
int palab = 0; | |
for (int i = 0; i < palabras.Length; i++) | |
{ | |
for (int j = 0; j < palabras[i].Length; j++) | |
{ | |
if (palabras[i][j] == 'a' || palabras[i][j] == 'e' || palabras[i][j] == 'i' || palabras[i][j] == 'o' || palabras[i][j] == 'u') | |
{ | |
vocales++; | |
} | |
} | |
if (vocales >= 3) | |
{ | |
vocales = 0; | |
palab++; | |
} | |
} | |
return palab; | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("Ingrese una frase"); | |
string frase = Console.ReadLine(); | |
Console.WriteLine("La frase tiene {0} palabras que tienen mas de 3 vocales", Frase.PalabrasVocales(frase)); | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment