Está en la página 1de 5

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace cadena
{
class Program
{
static void Main(string[] args)
{
int opc = 0;
string palabra;
int a = 0;
int b = 0;
int extense = 0;
int voc = 0;
char word;
int[] ascii = new int[20];
int ccar = 0;
int c = 0;
char[] codigo = new char[20];
//string correo;

while (opc != 6)
{
Console.WriteLine("Menu");
Console.WriteLine("1. Cadena Invertida");
Console.WriteLine("2. Caracteres Recorridos");
Console.WriteLine("3. Conteo de Vocales");
Console.WriteLine("4. Busqueda de Coincidencias");
Console.WriteLine("5. Es un correo?");
Console.WriteLine("6. Salir");

Console.WriteLine("\nEscribe la opcion que deseas:");
try
{
opc = Convert.ToInt32(Console.ReadLine());
}
catch (Exception)
{
}
switch (opc)
{
case 1:

try
{
for (a = 0; a < 10; a++)
{
Console.WriteLine("\nEscribe la palabra {0}", a+
1);
palabra = Console.ReadLine();
extense = Convert.ToInt32(palabra.Length);
Console.WriteLine("\nLa palabra {0} al reves", a
+ 1);
for (b = extense - 1; b >= 0; b--)
{
Console.Write("{0}", palabra[b]);
}
}
}
catch (Exception)
{
Console.WriteLine("Default");
}
break;
case 2:
try
{
for (a = 0; a < 10; a++)
{
Console.WriteLine("\nEscribe la palabra {0}", a
+ 1);
palabra = Console.ReadLine();
Console.WriteLine("\nCuantos caracteres desea rec
orrer?");
ccar = Convert.ToInt32(Console.ReadLine());
foreach (char carac in palabra)
{
ascii[c] = (int)carac;
c++;
}
for (b = 0; b < palabra.Length; b++)
{
if (ascii[b] == 121)
{
ascii[b] = 97;
}
else if (ascii[b] == 122)
{
ascii[b] = 98;
}
else
{
ascii[b] = ascii[b] + ccar;
}
}
c = 0;
foreach (char carac in palabra)
{
codigo[c] = (char)ascii[c];
c++;
}
Console.WriteLine("\nPalabra recorrida: ");
for (c = 0; c < palabra.Length; c++)
{
Console.Write("{0}", codigo[c]);
}
c = 0;
b = a;
}
}
catch (Exception)
{
Console.WriteLine("Error");
}
break;
case 3:
try
{
for (a = 0; a < 10; a++)
{
Console.WriteLine("\nEscribe la palabra {0}", a
+ 1);
palabra = Console.ReadLine();
voc = 0;
foreach (char carac in palabra)
{
if (carac == 'a')
{
voc = voc + 1;
}
else if (carac == 'e')
{
voc = voc + 1;
}
else if (carac == 'i')
{
voc = voc + 1;
}
else if (carac == 'o')
{
voc = voc + 1;
}
else if (carac == 'u')
{
voc = voc + 1;
}
}
Console.WriteLine("\nLa palabra {0} tiene {1} vo
cales", a + 1, voc);
}
}
catch (Exception)
{
Console.WriteLine("Error");
}
break;
case 4:
try
{
for (a = 0; a < 10; a++ )
{
Console.WriteLine("\nEscribe la palabra {0}", a
+ 1);
palabra = Console.ReadLine();
Console.WriteLine("\nQue letra deseas que se busq
ue?");
word = Convert.ToChar(Console.ReadLine());
b = 0;
for (b = 0; b < palabra.Length; b++)
{
if (palabra[b] == word)
{
ascii[b] = b + 1;
}
}
Console.WriteLine("\nLa letra '{0}' est en la pos
icin: ", word);
for (b = 0; b < palabra.Length; b++)
{
if (ascii[b] == 0)
{
}
else
{
Console.Write("[{0}]", ascii[b]);
}
}
for (b = 0; b < 20; b++)
{
ascii[b] = 0;
}
}
}
catch (Exception)
{
Console.WriteLine("Error");
}
break;



case 5:
try
{
for (a = 0; a < 10; a++)
{
Console.WriteLine("\nEscribe la palabra {0}", a
+ 1);
palabra = Console.ReadLine();
string correo = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+
)*\\.\\w+([-.]\\w+)*";
if (Regex.IsMatch(palabra, correo))
{
Console.WriteLine("\n{0} es un correo", pala
bra);
}
else
{
Console.WriteLine("\n{0} no es un correo", p
alabra);
}
}
}
catch (Exception)
{
Console.WriteLine("Error");
}
break;



default:
Console.WriteLine("\nOpcin no valida");
break;
}
}
}
}
}