进制转化简便用法
hex,Hexadecimal .十六进制。
dec,Decimal ,十进制。
oct,Octal ,八进制。
bin,Binary,二进制。
写出一个程序,输入一个十六进制的数值字符串,输出该数值的十进制字符串。
输入格式
输入包含多组测试数据。
每组数据占一行,包含一个十六进制的数值字符串。
输出格式
每组数据输出一行结果,表示给定数值的十进制字符串。
数据范围
每个输入最多包含 100 组数据。
所有答案均在 int 范围内。
输入样例:
0xA
输出样例:
10
#include <bits/stdc++.h>
using namespace std;
int a;
int main() {
while (cin >> hex >> a)
cout << dec << a << endl;
return 0;
}