伪代码的算法程序
newBase=int(input('请输入您想转换成的值的进制:
'))
decimalNumber=int(input('请输入您想转换的十进制值:
'))
quotient=1
m={10:'A',11:'B',12:'C',13:'D',14:'E',15:'F'}
list_=[]
while quotient != 0:
quotient=decimalNumber//newBase
remainder=decimalNumber%newBase
if remainder in m:
remainder=m[remainder]
list_.append(remainder)
decimalNumber=quotient
list_.reverse()
print('
')
print('结果是:')
for i in list_:
print(i,end='')
运行结果
二进制:
八进制:
十六进制: