Any hexadecimal to decimal

// hexadecimal to decimal conversion
#include <the iostream>
the using namespace STD;
const int N = 16;
const int = M. 8;
Long Long Convert (int A, S char []) // arbitrary hexadecimal to decimal
{
 Long Long Val = 0;
 for (int I = 0; S [I]; I ++)
 {
  IF (isdigit (S [I]))
      Val = Val * A + S [I] - '0';
  the else
      Val = Val * A + S [I] - 'A' + 10;
 }
 return Val;
}
 
int main (void)
{
 char S [M];
 Scanf ( "% S", S);
 Long Long A = Convert (N, S);
 COUT A << << endl;
 return 0;
 }

Guess you like

Origin www.cnblogs.com/cxwpluto/p/12432559.html