using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
int num, baseNum;
Console.Write("输入十进制数字: ");
num = Convert.ToInt32(Console.ReadLine());
Console.Write("选择进制类型[2/8/16]: ");
baseNum = Convert.ToInt32(Console.ReadLine());
Console.Write(num + "=>转换 ");
MulBase(num, baseNum);
Console.WriteLine(" 进制基数" + baseNum);
Console.Read();
}
static void MulBase(int n, int b)
{
Stack Digits = new Stack();
do
{
Digits.Push(n % b);
n /= b;
}
while (n != 0);
while (Digits.Count > 0)
Console.Write(Digits.Pop());
}
}
}