Problem Description:
write a program that accepts a hexadecimal value string and outputs the decimal string of the value (note that there may be multiple sets of data in a test case).
Input:
0xa
Output:
10
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
vector<char> conclude;
int CharToInt(char x){
if (x >= '0' && x <= '9'){
return x - '0';
}else{
return x - 'A' + 10;
}
}
void Convert(string str, int x){
int number = 0;
for(int i = 0; i < str.size(); ++i){
number *= x;
number += CharToInt(str[i]);
}
printf("%d\n", number);
}
int main(){
string str;
while (cin >> str){
str = str.substr(2);
Convert(str, 16);
}
return 0;
}
Read More:
- 【arm】arm-assembly-print-register-value-in-decimal
- Ant Design proformdigit fieldprops limits the number of decimal places entered
- Python conversion hex to string, high and low data processing
- Conversion to dalvik format failed with error 1 solution
- Error report of covertotraditional conversion from simplified to traditional
- Error: failed to find conversion function from unknown to text
- matlab Conversion to cell from char is not possible.
- Link: fatal error lnk1123: failure during conversion to coff: file in
- Error lnk1123: failure during conversion to coff: problem solving
- Conversion of audio file format with ffmpeg command
- C / C + + library function (tower / tower) realizes the conversion of letter case
- Visual Studio 2010 compilation error fatal error lnk1123: failed during conversion to coff: solution to invalid or corrupt file
- Mybatis uses step-by-step lazy loading to cause abnormal JSON conversion. The interface 500 reports an error
- Java lossy conversion
- Conversion between list and string array
- Local date time conversion in java8
- The conversion between [Python] bytes and hex strings.
- rmd to pdf error: pandoc document conversion failed with error 43
- LinkIssue: Error ‘LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or cor
- Mutual conversion between date and localdatetime