[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
内容目录
十进制如何转化为十六进制
思路解析
运用知识点
代码实现
1.十进制如何转化为十六进制
十六进制每位数上从大到小是0123456789ABCDEF
十进制转化为十六进制与十进制转化为八进制一样求法,就是求余。例如十进制数181的十六进制为B5
2.思路解析
"按照上面的求法可知就是求余,但是每次求余得到的数我们都要进行存储,这时候我们可以运用我们所学习的数组,将每次求余所得的数进行储存。
"但是储存过程中,因为十六进制中的10到15是由A到E的英文字母组成。这时候在进行储存中要将它转化为字母,这里我用的是switch语句进行搜索转换为字母,储存。
"这些完成之后,就需要在输出的时候注意一下,因为最终结果为逆序输出。
3.运用知识点
数组,switch语句,while循环语句
4.代码实现
#include <stdio.h> int main() { char a[16]; int b,c,i,m; printf("请输入一个十进制数:\n")
; scanf("%d",&b); c=1;i=0; while(b!=0) { c=b%16; switch(c) { case 0:a[i]='0';
break; case 1:a[i]='1';break; case 2:a[i]='2';break; case 3:a[i]='3';break; case
4:a[i]='4';break; case 5:a[i]='5';break; case 6:a[i]='6';break; case 7:a[i]='7';
break; case 8:a[i]='8';break; case 9:a[i]='9';break; case 10:a[i]='A';break;
case 11:a[i]='B';break; case 12:a[i]='C';break; case 13:a[i]='D';break; case 14:
a[i]='E';break; case 15:a[i]='F';break; } b=b/16; i+=1; } printf("十六进制数为:"); for
(m=i-1;m>=0;m--) { putchar(a[m]); } return 0; }
这里我用的是一个简单的方法,所以程序实现有些繁琐,但是适合C语言初学者更好的理解,与实现十进制转化为十六进制。