标签:std ios nbsp 基础练习 include col ace 基础 cin
#include <iostream> #include <string> #include <cmath> using namespace std; long long Dec; int main() { string Hex; int HexLength; while(cin >> Hex) { HexLength = Hex.length(); Dec = 0; for(int i = HexLength - 1; i >= 0; --i){ if(Hex[i] >= ‘0‘ && Hex[i] <= ‘9‘) Dec += pow(16, HexLength - 1 - i) * (Hex[i] - ‘0‘); else if(Hex[i] >= ‘A‘ && Hex[i] <= ‘F‘) Dec += pow(16, HexLength - 1 - i) * (Hex[i] - ‘A‘ + 10); } cout << Dec << endl; } }
标签:std ios nbsp 基础练习 include col ace 基础 cin
原文地址:https://www.cnblogs.com/XuYiting/p/9704376.html