当前位置:网站首页>Number system conversion (function)
Number system conversion (function)
2022-06-11 15:19:00 【Psychic hacker】
Title Description
Write function long change(char s[]), Its function is to convert the hexadecimal number represented by the parameter to the corresponding decimal integer
Input
Number of test data
The first hexadecimal number
The second hexadecimal number
.........
Output
The first decimal number
Second decimal number
........
sample input 1
3
1234
F8
AB12
sample output 1
4660
248
43794
Code
#include<iostream>
using namespace std;
long long change(char s[])
{
long long sum=0;
int i;
for(i=0;s[i];i++)
{
if(isdigit(s[i]))
sum=sum*16+s[i]-'0';
else
sum=sum*16+s[i]-'A'+10;
}
return sum;
}
int main()
{
int t;
cin>>t;
while(t--)
{
char num[20];
cin>>num;
cout<<change(num)<<endl;
}
}边栏推荐
- 多云安全合规扫描平台之RiskScanner
- 高数_第6章无穷级数__马克劳林级数
- 详解 Kubernetes 包管理工具 Helm
- Summary of redis basic knowledge
- 基于 GateWay 和 Nacos 实现微服务架构灰度发布方案
- Turning "passive" into "active", how to build security compliant intelligent products | Q recommendation
- 汤峥嵘:CTO 是商业思维和技术思维交汇的那个点
- Database optimization
- Can we really make money by doing we media editing?
- Uniapp settings page Jump effect - navigateto switching effect - Global animationtype animation
猜你喜欢

How to play seek tiger, which has attracted much attention in the market?

Station B executives interpret the financial report: the epidemic has no impact on the company's long-term development, and the video trend is irresistible

腾讯面试官分享面试经验,如何考察面试者技术及个人综合素质,给正在面试的你一点建议

Ali, tell me about the application scenarios of message oriented middleware?

Implementation of gray-scale publishing scheme for microservice architecture based on gateway and Nacos

19. insertion, deletion and pruning of binary search tree

Knowledge of affairs

基于 GateWay 和 Nacos 实现微服务架构灰度发布方案

19. Insertion et suppression d'un arbre de recherche binaire

3年亏损136亿,上市能救活威马吗?
随机推荐
07 _ Functions and disadvantages of row lock: how to reduce the impact of row lock on performance?
基于STM32F1的开源小项目
Implementation of gray-scale publishing scheme for microservice architecture based on gateway and Nacos
Did you break the rules?
[multi thread performance tuning] what operations cause context switching?
浅谈居家办公后的感想| 社区征文
How to play seek tiger, which has attracted much attention in the market?
Installation and use of sonarqube
uniapp開發微信小程序,從構建到上線
Basic configuration command of Xinhua 3 switch system
Managing technology debt in a microservice architecture
Backtracking / activity scheduling maximum compatible activities
你还不懂线程池的设计及原理吗?掰开揉碎了教你设计线程池
Elk log analysis system
回溯法/解空间树 排列树
Tencent interviewers share their interview experience, how to evaluate the interviewers' technical and personal comprehensive quality, and give you some suggestions on the interview
Flower shop window (linear DP)
02 Tekton Pipeline
2021 年 CNCF 调查:Kubernetes 跨越鸿沟的一年
Raspberry pie obtains the function of network installation system without the help of other devices