当前位置:网站首页>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;
}边栏推荐
- P6117-[JOI 2019 Final]コイン集め【贪心】
- 浮点数表示法(总结自CS61C和CMU CSAPP)
- From the Huawei weautomate digital robot forum, we can see the "new wisdom of government affairs" in the field of government and enterprises
- Vidéo courte recommandée chaque semaine: Soyez sérieux en parlant de "métaunivers"
- Easyexcel single sheet and multi sheet writing
- 十二、所有功能实现效果演示
- Depens:*** but it is not going to be installed
- 深入解析 Apache BookKeeper 系列:第三篇——读取原理
- 当程序员被问会不会修电脑时… | 每日趣闻
- Yolox backbone -- implementation of cspparknet
猜你喜欢

110. balanced binary tree recursive method
Depens:*** but it is not going to be installed

CF566E-Restoring Map【bitset】

Groovy通过withCredentials获取Jenkins凭据

活动报名|Apache Pulsar x KubeSphere 在线 Meetup 火热报名中

Every (), map (), forearch () methods. There are objects in the array

Zero foundation self-study SQL course | having clause

Target detection series fast r-cnn

Data midrange: detailed explanation of the technical stack of data acquisition and extraction

目标检测系列——Fast R-CNN
随机推荐
P6117-[JOI 2019 Final]コイン集め【贪心】
Squid代理服务器应用
读CVPR 2022目标检测论文得到的亿点点启发
【gdb调试工具】| 如何在多线程、多进程以及正在运行的程序下调试
Weekly recommended short video: talk about "meta universe" with a serious attitude
十二、所有功能实现效果演示
Alibaba Senior Software Testing Engineer recommends testers to learn -- Introduction to security testing
LeetCode之最长公共前缀
Implementation process of tcpdump packet capturing
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
牛客网 十进制整数转十六进制字符串
What do you mean by waiting for insurance records? Where should I go for filing?
陆奇:我现在最看好这四大技术趋势
linux(centos7.9)安装部署mysql-cluster 7.6
[e325: attention] VIM editing error
Applet wx show
零基础自学SQL课程 | 子查询
EasyExcel单sheet页与多sheet页写出
Unable to change the virtual machine power status and report an error solution
Pytoch read data set (two modes: typical data set and user-defined data set)