Skip to content

Commit

Permalink
Merge pull request mouredev#6018 from deathwing696/main
Browse files Browse the repository at this point in the history
Reto mouredev#47 - c#
  • Loading branch information
kontroldev authored Dec 9, 2023
2 parents f78a069 + ec4493d commit baa8946
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ public class Reto47
{
static void Main(string[] args)
{
string palabra;
string palabra, cadena;
int puntos = 0;

do
{
Console.Write("Introduce una palabra que tenga una puntuación igual o mayor a 100 puntos:");
palabra = Console.ReadLine();
cadena = Console.ReadLine();
palabra = Obtener_primera_palabra(cadena);
puntos = Calcula_puntos(palabra);
Console.WriteLine($"La palabra {palabra} tiene {puntos} puntos");
} while (puntos < 100);
Expand Down Expand Up @@ -76,5 +77,17 @@ static private string Quitar_acentos(string palabra)

return salida.ToString().Normalize(NormalizationForm.FormC);
}

static private string Obtener_primera_palabra(string cadena)
{
string[] palabras;
string primera_palabra;

palabras = cadena.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

primera_palabra = palabras.Length > 0 ? palabras[0] : String.Empty;

return primera_palabra;
}
}
}

0 comments on commit baa8946

Please sign in to comment.