当前位置:网站首页>3438. Number system conversion
3438. Number system conversion
2022-07-19 14:55:00 【Ray. C.L】

Ideas : take a Hexadecimal number number Turn into 10 Base number ( Qin Jiushao ), And then divide by short to b Base number
Code :
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
char itoc(int x){
if(x < 10) return '0' + x;
return 'A' + x - 10;
}
int ctoi(char x){
if(x <= '9') return x - '0';
if(x <= 'Z') return x - 'A' + 10;
return x - 'a' + 10;
}
int main()
{
int n, a, b;
string number;
cin >> a >> number >> b;
n = 0;
for(auto c : number) n = n * a + ctoi(c);
string res;
while(n) res += itoc(n % b) , n /= b;
reverse(res.begin(), res.end());
cout << res << endl;
return 0;
}
边栏推荐
- TDesign 在 vitest 的实践
- 2021 年全国职业院校技能大赛 网络搭建与应用赛项
- Several points to be analyzed in the domestic fpga/dsp/zynq scheme
- 程序员 运维那些高薪的背后
- Which company is better in data filling and report presentation? Yixin ABI gives you the answer
- LabVIEW uses multithreading. Will the program run faster
- Explain C language dynamic memory management in detail
- 009 execution sequence of SQL statement of interview questions
- Redis source code and design analysis -- 1 Simple dynamic string
- 2021.07.13【B站】是这样崩的
猜你喜欢

滑动窗口最大值问题

Win10 Microsoft Store cannot be opened (enable TLS 1.2)

Sliding window maximum problem

MySQL index (I)

Deep understanding of transaction isolation levels

MVCC多版本并发控制

High performance pxie data preprocessing board based on kinex ultrascale series FPGA (ku060 +fmc sub card interface)

Qchartview overwrites the previous control when it is added in qgridlayout
Sub database and sub table

LabVIEW uses multithreading. Will the program run faster
随机推荐
Several points to be analyzed in the domestic fpga/dsp/zynq scheme
中断的分类
抽象类与派生类
OSError: sndfile library not found 解决方案
1、DBMS基本概念
kube-proxy & Service & Endpoint
详解C语言文件操作
ORA-08103
[port 3000 is already in use, solution to the problem of 3000 port being occupied]
程序员 运维那些高薪的背后
Comparaison de deux types de machines virtuelles
009 execution sequence of SQL statement of interview questions
The bill module of freeswitch
PCIe Cameralink signal generator (Cameralink image analog source)
Read the paper: temporary graph networks for deep learning on dynamic graphs
Single channel 6Gsps 12 bit AD acquisition and single channel 6Gsps 16 bit Da (ad9176) output sub card based on vita57.1 standard
SQL wrong questions set of Niuke brush questions
MySQL read / write separation
Oserror: sndfile library not found solution
Excellent jar package startup shell script collection