当前位置:网站首页>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;
}边栏推荐
- [redis implements seckill business ①] seckill process overview | basic business implementation
- Ebanb B1 Bracelet brush firmware abnormal interrupt handling
- Linux (centos7.9) installation and deployment of MySQL Cluster 7.6
- Xiaobai needs to learn MySQL - incremental statistical SQL
- Groovy通过withCredentials获取Jenkins凭据
- jupyter入门常见的几个坑:
- The native applet uses canvas to make posters, which are scaled to the same scale. It is similar to the uniapp, but the writing method is a little different
- EasyExcel单sheet页与多sheet页写出
- Digital cloud released the 2022 white paper on digital operation of global consumers in the beauty industry: global growth solves marketing problems
- [Niuke] length of the last word of HJ1 string
猜你喜欢

Leetcode -- wrong set

Support vector machine (SVC, nusvc, linearsvc)

"Unusual proxy initial value setting is not supported", causes and Solutions

小白学习MySQL - 增量统计SQL的需求

Transplantation of xuantie e906 -- fanwai 0: Construction of xuantie c906 simulation environment

Digital cloud released the 2022 white paper on digital operation of global consumers in the beauty industry: global growth solves marketing problems

Lu Qi: I am most optimistic about these four major technology trends
![[e325: attention] VIM editing error](/img/58/1207dec27b3df7dde19d03e9195a53.png)
[e325: attention] VIM editing error

目标检测系列——Fast R-CNN

Redis implements a globally unique ID
随机推荐
Qingcloud based R & D cloud solution for geographic information enterprises
YOLOX backbone——CSPDarknet的实现
MySQL | view notes on Master Kong MySQL from introduction to advanced
[bug] @jsonformat has a problem that the date is less than one day when it is used
Leetcode -- wrong set
threejs辉光通道01(UnrealBloomPass && layers)
P6117-[JOI 2019 Final]コイン集め【贪心】
2022-06-23: given a nonnegative array, select any number to make the maximum cumulative sum a multiple of 7, and return the maximum cumulative sum. N is larger, to the 5th power of 10. From meituan. 3
Depens:*** but it is not going to be installed
[noi simulation] pendulum (linear algebra, Du Jiao sieve)
每周推荐短视频:谈论“元宇宙”要有严肃认真的态度
Jincang KFS replicator installation (oracle-kes)
Depens:*** but it is not going to be installed
当程序员被问会不会修电脑时… | 每日趣闻
On the routing tree of gin
华为路由器:ipsec技术
Time Series Data Augmentation for Deep Learning: A Survey 之论文阅读
零基础自学SQL课程 | 相关子查询
[use picgo+ Tencent cloud object to store cos as a map bed]
Digital cloud released the 2022 white paper on digital operation of global consumers in the beauty industry: global growth solves marketing problems