1. #include <iostream>
    2. #include <type_traits>
    3. #include <vector>
    4. #include <algorithm>
    5. using namespace std;
    6. int getInt(char ch) {
    7. if (ch >= '0' && ch <= '9') {
    8. return ch - '0';
    9. }
    10. return ch - 'a' + 10;
    11. }
    12. char getChar(int val) {
    13. if (val <= 9) {
    14. return '0' + val;
    15. }
    16. return val - 10 + 'a';
    17. }
    18. string calc36String(string nums1, string nums2) {
    19. int carry = 0;
    20. int i = nums1.size() - 1, j = nums2.size() - 1;
    21. string res;
    22. while (i >= 0 || j >= 0 || carry) {
    23. int x = i >= 0 ? getInt(nums1[i]) : 0;
    24. int y = j >= 0 ? getInt(nums2[j]) : 0;
    25. carry += x + y;
    26. res += getChar(carry % 36);
    27. carry /= 36;
    28. i--, j--;
    29. }
    30. reverse(res.begin(), res.end());
    31. return res;
    32. }
    33. int main() {
    34. cout << calc36String("1b", "2x") << endl;
    35. return 0;
    36. }