using System;
using System.Collections.Generic;
using System.Text;
namespace Demo {
class MyApplication {
static void Main(string[] args) {
int num, binVal, decVal = 0, baseVal = 1, rem;
num = 101;
binVal = num;
while (num > 0) {
rem = num % 10;
decVal = decVal + rem * baseVal;
num = num / 10 ;
baseVal = baseVal * 2;
}
Console.Write("Binary Number: "+binVal);
Console.Write("/nDecimal: "+decVal);
Console.ReadLine();
}
}
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/265913.html