当前位置:网站首页>十六进制字符→十进制数字
十六进制字符→十进制数字
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("这不是十六进制的基数!");
}
}
边栏推荐
猜你喜欢
1-hour live broadcast recruitment order: industry big names share dry goods, and enterprise registration opens丨qubit·viewpoint
无重复字符的最长子串
900页数学论文证明旋转的黑洞不会爆炸,丘成桐:30多年来广义相对论首次重大突破...
ABAP interview questions: how to use the System CALL interface of the ABAP programming language, direct execution ABAP server operating System's shell command?
The new features of ABP 6.0.0 - rc. 1
腾讯欲成育碧最大股东/ 米哈游招NLP内容生成研究员/ AI发现四千余物种濒临灭绝...今日更多新鲜事在此...
Intranet penetration tool ngrok usage tutorial
Flutter Getting Started and Advanced Tour (4) Text Input Widget TextField
已解决IndentationError: unindent does not match any oute r indentation Level
win10编译x264库(也有生成好的lib文件)
随机推荐
World's 4th mad scientist dies on his 103rd birthday
Go-based web access parameters
ERP不规范,同事两行泪 (转载非原创)
【TKE】GR+VPC-CNI混用模式下未产品化功能配置
张朝阳对话俞敏洪:一边是手推物理公式,一边是古诗信手拈来
Two minutes recording can pass by second language!The volcano how to practice and become voice tone reproduction technology?
26. Pipeline parameter substitution command xargs
Flutter introduction advanced trip (5) Image Widget
用皮肤“听”音乐,网友戴上这款装备听音乐会:仿佛住在钢琴里
Flutter Getting Started and Advanced Tour (4) Text Input Widget TextField
8、IDEA提交代码出现: Fetch failed fatal: Could not read from remote repository
[HCIP Continuous Update] Principle and Configuration of IS-IS Protocol
基于CAP组件实现补偿事务与幂等性保障
非科班AI小哥火了:他没有ML学位,却拿到DeepMind的offer
Customize VIEW to realize in-app message reminder to rotate up and down
Scala 高阶(七):集合内容汇总(上篇)
【HCIP持续更新】IS-IS协议原理与配置
The grep command Shell regular expressions, the three musketeers
鹅厂机器狗花式穿越10m梅花桩:前空翻、单桩跳、起身作揖...全程不打一个趔趄...
字符串转换整数 (atoi)