进制转换的相互转换习题
????????? ??????????????????????????8? ????????????????????? ??????????????? ????????? ?????????16?????? ?????0-9?????10-15???A-F? ??????????????
发布日期:2021-04-30 21:06:01
浏览次数:93
分类:精选文章
本文共 2531 字,大约阅读时间需要 8 分钟。
????????????????????????????????????????????????????????????????????????????????????????
?????????
???????????????????????Java?????????????????
????????
str??????????public static void Fa() { Scanner sr = new Scanner(System.in); int s = sr.nextInt(); String str = ""; while (s >= 8) { str += s % 8; s = s / 8; } str = str + s; StringBuffer sb = new StringBuffer(str); System.out.println(sb.reverse());} ??????????
Java???Integer.toOctalString(int)??????????????????????
public static void Fb() { Scanner sr = new Scanner(System.in); int a = sr.nextInt(); if (0 <= a && a <= 2147483647) { System.out.println(Integer.toOctalString(a)); }} ??????????
???????????????0?15???????10?15????????A?F?
????????
str?public static void Za() { Scanner sr = new Scanner(System.in); int s = sr.nextInt(); String str = ""; while (s >= 16) { str += s % 16; s = s / 16; } switch (str) { case "10": str += "A"; break; case "11": str += "B"; break; case "12": str += "C"; break; case "13": str += "D"; break; case "14": str += "E"; break; case "15": str += "F"; break; default: str = s + str; break; } System.out.println(str);} ??????????
Java?Integer.toHexString(int)??????????????????????????????????toUpperCase()????????
public static void Zb() { Scanner sr = new Scanner(System.in); int a = sr.nextInt(); if (0 <= a && a <= 2147483647) { String b = Integer.toHexString(a).toUpperCase(); System.out.println(b); }} ??????????
?????????????????????????????????
public static void main(String[] args) { Scanner sr = new Scanner(System.in); int a = sr.nextInt(); System.out.println(Integer.toOctalString(a));} ??????????
????????????????????????????????
public static void main(String[] args) { Scanner sr = new Scanner(System.in); String a16 = sr.next(); char[] b16 = a16.toCharArray(); int a10 = 0; for (int i = 0; i < b16.length; i++) { a10 += xia(b16[i]) * Math.pow(16, b16.length - 1 - i); } System.out.println(a10);}public static int xia(int ace) { char[] wt = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; for (int i = 0; i < wt.length; i++) { if (wt[i] == ace) { return i; } } return -1;} ???????????????????????????
发表评论
最新留言
关注你微信了!
[***.104.42.241]2026年06月03日 23时07分45秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
php实现根据身份证获取年龄
2023-03-01
PHP实现的MongoDB数据增删改查
2023-03-01
PHP实现的SSO单点登录系统,拿走就用吧
2023-03-01
php实现短信验证功能
2023-03-01
php实现逆转数组
2023-03-01
PHP实现通过geoip获取IP地理信息
2023-03-01
PHP实现页面静态化、纯静态化及伪静态化
2023-03-01
php容许ajax跨域,PHP设置允许ajax跨域请求的两种常见方法
2023-03-01
RabbitMQ进程结构分析与性能调优
2023-03-01
PHP对接百度地图
2023-03-01
PHP对表单提交特殊字符的过滤和处理
2023-03-01
php对象引用和析构函数的关系
2023-03-01
RabbitMQ HTTP 认证后端项目常见问题解决方案
2023-03-01
PHP将图片转换成base64格式(优缺点)
2023-03-01
php将多个值的数组去除重复元素
2023-03-01
php局域网上传文件_PHP如何通过CURL上传文件
2023-03-01
PHP工具插件大全
2023-03-01
php布尔值的++
2023-03-01
PHP常量、变量作用域详解(一)
2023-03-01