当前位置:网站首页>Niuke network decimal integer to hexadecimal string
Niuke network decimal integer to hexadecimal string
2022-06-24 09:16:00 【SZU healing system bug】
Catalog
Title Description
Write a function , Pass in a positive decimal integer , Converts a decimal integer to a hexadecimal string and returns .( All the letters in the hexadecimal string are capitalized )
Input description :
Keyboard input a decimal positive integer
Output description :
Output the hexadecimal string after decimal integer conversion
Example 1
Input :
162
Copy output :
A2
Copy
Example 2
Input :
50
Copy output :
32
Copy
Example 3
Input :
501
Copy output :
1F5
Thought analysis
The idea is simple , It is calculated according to the decimal to hexadecimal algorithm , Divide 16 Remainder , The key is flexible invocation string Class to complete the insertion work .
AC Code
#include<iostream>
#include<string>
using namespace std;
int main(){
string hex;
char bit;
int deci;
cin>>deci;
do{
if(deci%16<10)
bit=deci%16+'0';
else
bit=deci%16+'A'-10;
hex.insert(hex.begin(),bit);
deci/=16;
}while(deci);
cout<<hex;
}边栏推荐
- 解决:jmeter5.5在win11下界面上的字特别小
- "Unusual proxy initial value setting is not supported", causes and Solutions
- Linux (centos7.9) installation and deployment of MySQL Cluster 7.6
- How to configure environment variables and distinguish environment packaging for multi terminal project of uniapp development
- [ES6 breakthrough] promise is comparable to native custom encapsulation (10000 words)
- 2022.6.13-6.19 AI行业周刊(第102期):职业发展
- EasyExcel单sheet页与多sheet页写出
- 关于 GIN 的路由树
- 零基础自学SQL课程 | HAVING子句
- P6117-[JOI 2019 Final]コイン集め【贪心】
猜你喜欢

Qingcloud based "real estate integration" cloud solution

【bug】@JsonFormat 使用时出现日期少一天的问题

学习太极创客 — ESP8226 (十三)OTA

Redis实现全局唯一ID

jupyter入门常见的几个坑:

Opencv maximum filtering (not limited to images)
![[redis implements seckill business ①] seckill process overview | basic business implementation](/img/a3/9a50e83ece43904a3a622dcdb05b3c.png)
[redis implements seckill business ①] seckill process overview | basic business implementation
![[quantitative investment] discrete Fourier transform to calculate array period](/img/0d/aac02463ff403fb1ff871af5ff91fa.png)
[quantitative investment] discrete Fourier transform to calculate array period

零基础自学SQL课程 | HAVING子句
![[bug] @jsonformat has a problem that the date is less than one day when it is used](/img/09/516799972cd3c18795826199aabc9b.png)
[bug] @jsonformat has a problem that the date is less than one day when it is used
随机推荐
2022.6.13-6.19 AI行业周刊(第102期):职业发展
Spark - LeftOuterJoin 结果条数与左表条数不一致
Data middle office: middle office architecture and overview
How to import MDF and LDF files into MySQL workbench
Numpy NP in numpy c_ And np r_ Explain in detail
110. balanced binary tree recursive method
Huawei Router: IPSec Technology
Tools
MySQL | store notes of Master Kong MySQL from introduction to advanced
从618看京东即时零售的野心
Ebanb B1 Bracelet brush firmware abnormal interrupt handling
2022.06.23 (traversal of lc_144,94145\
Remote connection of raspberry pie without display by VNC viewer
[redis realize Secondary killing Business ①] Overview of Secondary killing Process | Basic Business Realization
MySQL data (Linux Environment) scheduled backup
Lu Qi: I am most optimistic about these four major technology trends
On the routing tree of gin
【输入法】迄今为止,居然有这么多汉字输入法!
2020 China's provinces and cities, three-level linkage data, data agencies (data from the official website of the National Bureau of Statistics)
零基础自学SQL课程 | SQL语句语法顺序与执行顺序