elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Rompecabezas de Bitcoin, Medio millón USD en premios


  Mostrar Mensajes
Páginas: [1]
1  Programación / .NET (C#, VB.NET, ASP) / Re: Ayuda ; [C#] Algoritmo para saber si un Nº es capicua. en: 1 Enero 2010, 01:50 am
ahi te dejo otra forma de hacer el Capicua... yo tmb soy novato.

Código
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace ConsoleApplication1
  6. {
  7.    class Class1
  8.    {
  9.        public static void Main()
  10.        {
  11.            string cadena = "";
  12.  
  13.            Console.Write("Ingrese Numero :");
  14.            int n = int.Parse(Console.ReadLine());
  15.            string x = Convert.ToString(n);
  16.            do
  17.            {
  18.                int r = n % 10;
  19.                cadena = string.Concat(cadena,r);
  20.                n = n / 10;
  21.  
  22.            } while (n != 0);
  23.  
  24.            if (cadena == x)
  25.                Console.Write("Es capicua ");
  26.            else
  27.                Console.Write("No es capicua ");
  28.            Console.Read();
  29.  
  30.        }
  31.    }
  32. }
  33.  
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines