Skip to content

Instantly share code, notes, and snippets.

@Reflej0
Created April 6, 2017 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Reflej0/5e71742145db231c5533c7cd3291c3bf to your computer and use it in GitHub Desktop.
Save Reflej0/5e71742145db231c5533c7cd3291c3bf to your computer and use it in GitHub Desktop.
Algoritmo en C# para encontrar las palabras terminadas en cion, dentro de una frase con varias palabras.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Ingrese una frase");
string frase = Console.ReadLine();
string[] palabras = frase.Split(' ');
int palabrascion = 0;
for (int i = 0; i < palabras.Length; i++)
{
if (palabras[i][palabras[i].Length - 1] == 'n' && palabras[i][palabras[i].Length - 2] == 'o' && palabras[i][palabras[i].Length - 3] == 'i' && palabras[i][palabras[i].Length - 4] == 'c')
{
palabrascion++;
}
}
Console.WriteLine("Las palabras terminadas en cion son:{0}", palabrascion);
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment