You are on page 1of 1

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BinarioDecimal
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("ingresa tama�o del binario");
int valorDecimal =0;
int tamanio = int.Parse(Console.ReadLine());

// declaracion del arreglo

int[] binario = new int[tamanio];

bool isValidoCaracter = true;


char c = ' ';
int i = 0;
Console.WriteLine("ingresa numero binario");
do
{
c = Convert.ToChar(Console.Read());
if (c != '\r')
{
if (c == '1')
{
binario[i] = 1;
}
else
{
binario[i] = 0;
}
i++;
}
else
{
isValidoCaracter = false;
}

} while (isValidoCaracter != false);


int potencia = 0;
for (int j = 3; j >= 0; j--)
{
int valorArreglo = binario[j];
if (valorArreglo == 1)
{
potencia += 1;
// SACAR POTENCIA
}
valorDecimal += potencia;
}
}
}
}

You might also like