键盘输入一长度为3的八进制字符串,编写程序将该八进制字符串转换为相应的十进制数并输出结果。例如输入字符串"100",输出结果为64。
static void Main()
{
string str;
int x = 1, num = 0;
str = Console.ReadLine();
while (str.Length > 0)
{
num += x * int.Parse(str.Substring(str.Length - 1, 1));
str = str.Remove(str.Length - 1);
x *= 8;
}
Console.WriteLine(num);
}