Number of hexadecimal values: char * sum (int n, char * num1, char * num2)
Function:
The first parameter n represents the number of hexadecimal values. The maximum value is 36, from 0 to 9, and then A to Z represents 10 to 35.
Char * num1 and char * num2 accept two numeric strings respectively, and then return the result after adding them.
# include using namespace STD; // n indicates the number of hexadecimal digits // A indicates the number of operands 1 // B indicates the number of operands 2 // JY indicates the number of incoming digits // whether jy1 carries char sum1 (INT N, char, char B, int JY, int * jy1) {int num1 = 0; int num2 = 0; If (isdigit (A) num1 = A-'0 '; else num1 = A-'A' + 10; If (isdigit (B) num2 = B-'0'; else num2 = B-'A' + 10; if (num1 + num2 + JY> N) {int temp = num1 + num2 + JY-N; * jy1 = 1; if (temp <10) {return '0' + temp;} else {return 'A' + temp-10;} else {int temp = num1 + num2 + JY; * jy1 = 0; If (temp <10) {return '0' + temp;} else {return 'A' + temp-10 ;}}} char * sum (int n, char * num1, char * num2) {int num1_len = strlen (num1); int num2_len = strlen (num2); int max = num1_len> num2_len? Num1_len: num2_len; int JY = 0; char * He = new char [Max + 2]; memset (HE, 0, Max + 2); For (INT I = 0; I = 0) {A = num1 [num1_len-1-i];} else {A = '0';} If (num2_len-1-i> = 0) {B = num2 [num2_len-1-i];} else {B = '0 ';} he [I] = sum1 (n, a, B, JY, & JY);} return he;} int main () {char * num1 = new char [100]; char * num2 = new char [100]; int N; while (CIN> num1> num2> N) {char * P = sum (n, num1, num2 ); for (INT I = 0; I
Number of hexadecimal values: char * sum (int n, char * num1, char * num2)