Solução: Problema do número espelho (Timoteo Sales)

From AdonaiMedrado.Pro.Br
Jump to: navigation, search
using System;
 
namespace NumeroEspelho
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int numeroDecimal = int.Parse(Console.ReadLine(), System.Globalization.NumberStyles.HexNumber);
			string numeroEspelho = numeroDecimal.ToString();
 
			int tamanho = numeroEspelho.Length - 1;
			int teste = -1;
			for(int i = 0; i <= tamanho / 2; i++){
 
				string a = numeroEspelho.Substring(i,1);
				string b = numeroEspelho.Substring(tamanho-i,1);			
				if (a == b)
					teste = i+1;
                               else
                                       break;
			}
 
			if (teste >= (tamanho)/2)
				Console.WriteLine('S');
			else
				Console.WriteLine('N');
		}
	}
}