当前位置:网站首页>十六进制字符→十进制数字
十六进制字符→十进制数字
2022-08-09 12:25:00 【进击的李知因】
import java.util.Scanner;
public class Case11_0XcharToNumber{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("请输入0~9、A~F或a~f之间的一个字符:");
String s = in.next();//输入一个字符串
char x = s.charAt(0);//截取第一个字符
if(x >= 48 && x <= 57)//0~9
System.out.println(x + "的十进制表示为:"+ x);
else if(x >= 65 && x <= 70)//A~F
System.out.println(x + "的十进制表示为:"+ (x - 'A' + 10));
else if(x >= 97 && x <= 102)//a~f
System.out.println(x + "的十进制表示为:"+ (x - 'a' + 10));
else
System.out.println("这不是十六进制的基数!");
}
}
边栏推荐
- MySQL 原理与优化,Group By 优化 技巧
- Intranet penetration tool ngrok usage tutorial
- Scala Advanced (7): Collection Content Summary (Part 1)
- Rust 入门指南(使用JSON)
- AQS同步组件-FutureTask解析和用例
- 保存Simulink仿真模型为图片或者PDF的方法
- Flutter入门进阶之旅(一)-初识Flutter
- The core key points of microservice architecture
- 报告:想学AI的学生数量已涨200%,老师都不够用了
- JVM内存泄漏和内存溢出的原因
猜你喜欢
ABAP interview questions: how to use the System CALL interface of the ABAP programming language, direct execution ABAP server operating System's shell command?
听声辨物,这是AI视觉该干的???|ECCV 2022
00后写个暑假作业,被监控成这笔样
国产抗新冠口服药每瓶不超300元/ 我国IPv6网络全面建成/ 谷歌入局折叠屏手机...今日更多新鲜事在此...
Rust从入门到精通04-数据类型
30行代码实现蚂蚁森林自动偷能量
西湖大学教授怎么看AI制药革命?|量子位智库圆桌实录
一甲子,正青春,CCF创建六十周年庆典在苏州举行
新起之秀 DPU,正在掀起数据中心变革!
Flutter入门进阶之旅(三)Text Widgets
随机推荐
大佬们,请教一下,我看官方文档中,sqlserver cdc只支持2012版之后的,对于sqlser
批量读取word docx文件指定表格内容,保存在excel文件中
数字化转型之支撑保障单元
Do you know the difference between comments, keywords, and identifiers?
Scala 高阶(七):集合内容汇总(上篇)
手写大根堆
Fragment中嵌套ViewPager数据空白页异常问题分析
ansible-cmdb friendly display ansible collects host information
Manchester city launch emotional intelligence scarf can be detected, give the fans
苹果Meta都在冲的Pancake技术,中国VR团队YVR竟抢先交出产品答卷
h264协议
1小时直播招募令:行业大咖干货分享,企业报名开启丨量子位·视点
使用RecyclerView实现三级折叠列表
中断系统结构及中断控制详解
Adalvo收购其首个品牌产品Onsolis
Extract EventBus encapsulation to base class using annotations
World's 4th mad scientist dies on his 103rd birthday
Flutter入门进阶之旅(五)Image Widget
Flutter Getting Started and Advanced Tour (3) Text Widgets
WeChat Mini Program Payment and Refund Overall Process