当前位置:网站首页>【C语言】进制转换一般方法
【C语言】进制转换一般方法
2022-07-31 02:45:00 【rookieﻬ°】
我们废话不多说,直接上代码:
//这里我们设把一个10进制的数,转换为6进制的数(以此类推)
int main()
{
int n = 0;
scanf("%d", &n);
int change_num = 0;//设change_num为最终得到的结果
int ret = 1;//进制转换必须设的数
while (n)
{
change_num += ret * (n % 6);//重点!!
n /= 6;
ret *= 10;
}
printf("%d\n", change_num);
return 0;
}
言简意赅,喜欢的记得留下赞哦~~
边栏推荐
猜你喜欢
Manchester City confuses fans with smart scarf that detects emotions
7. List of private messages
11. Redis implements follow, unfollow, and follow and follower lists
10. Redis implements likes (Set) and obtains the total number of likes
图解lower_bound&upper_bound
11、Redis实现关注、取消关注以及关注和粉丝列表
Introduction to flask series 】 【 flask - using SQLAlchemy
CMOS和TTL的区别?
什么是分布式锁?实现分布式锁的三种方式
Static route analysis (the longest mask matching principle + active and standby routes)
随机推荐
mysql view
编译Hudi
知识蒸馏7:知识蒸馏代码详解
Huawei od dice js
10. Redis implements likes (Set) and obtains the total number of likes
Inter-vlan routing + static routing + NAT (PAT + static NAT) comprehensive experiment
11、Redis实现关注、取消关注以及关注和粉丝列表
How to design the changing system requirements
开题报告之论文框架
STM32CUBEMX开发GD32F303(11)----ADC在DMA模式下扫描多个通道
f.grid_sample
YOLOV5学习笔记(二)——环境安装+运行+训练
TCP/IP四层模型
【shell基础】判断目录是否为空
Unity3D Button mouse hover enter and mouse hover exit button events
Live Preview | KDD2022 Doctoral Dissertation Award Champion and Runner-up Dialogue
关于 mysql8.0数据库中主键位id,使用replace插入id为0时,实际id插入后自增导致数据重复插入 的解决方法
Difference between CMOS and TTL?
6、显示评论和回复
AI在医疗影像设备全流程应用