实现进制转换伪代码

伪代码的算法程序
newBase=int(input('请输入您想转换成的值的进制:\n'))
decimalNumber=int(input('请输入您想转换的十进制值:\n'))
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('\n')
print('结果是:')
for i in list_:
print(i,end='')

运行结果
二进制:

八进制:

十六进制:

posted @   20201319吴向林  阅读(274)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示