用户输入三个字符,每个字符取值范围是0-9,A-F。然后程序会把这三个字符转化为相应的十六进制整数,并分别以十六进制,十进制,八进制输出,十六进制表示成3位,八进制表示成4位,若不够前面补0。(不考虑输入不合法的情况)
输入
1D5
输出
(注意冒号后面有一个空格)
Hex: 0x1D5
Decimal: 469
Octal: 0725
#include <iostream>
#include <cstdio>
#include <math.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <vector>
using namespace std;
typedef long long ll;
void hexToOct(string str){
string res = "";
for(int i=0;i<str.length();i++){
switch(str[i]){
case '0': res += "0000";
break;
case '1': res += "0001";
break;
case '2': res += "0010";
break;