#include<iostream>
#include<string>
using namespace std;
int main()
{ 
    string zq; 
    int result=0; 
    while (cin >> zq) 
    { 
        for (int i = 0; i < zq.size(); ++i) 
            result += (zq[i] - 'A' + 1)*pow(26, zq.size()-i-1); 
        cout << result << endl; 
        result = 0; 
    return 0;
} 
同样,字节面试36进制加法,多了一步转换回36进制的步骤。

#include<iostream>
#include<string>
using namespace std;
int main()
{
    string a, b,result;//36进制
    int ad=0, bd=0,resultd=0,temp=0;//十进制
    cin >> a >> b;
    for (int i = 0; i < a.size(); ++i)//a转换十进制
    {
        if(isdigit(a[i]))
        ad += ((a[i]-'0')*pow(36,a.size()-1-i));
        if (islower(a[i]))
        ad += ((a[i] - 'a'+10)*pow(36, a.size()-1-i));//a代表10
        if (isupper(a[i]))
            ad += ((a[i] - 'A' + 10)*pow(36, a.size() - 1 - i));//A代表10
    }
    for (int i = 0; i < b.size(); ++i)//b转换十进制
    {
        if (isdigit(b[i]))
            bd += ((b[i] - '0')*pow(36, b.size() - 1 - i));
        if (isalpha(b[i]))
            bd += ((b[i] - 'a' + 10)*pow(36, b.size() - 1 - i));//a代表10
        if (isupper(b[i]))
            bd += ((b[i] - 'A' + 10)*pow(36, a.size() - 1 - i));//A代表10
    }
    resultd = ad + bd;//十进制结果
    while (resultd != 0)
    {
        temp=resultd % 36;
        resultd /= 36;
        if (temp < 10)
            result += (char)(temp+'0');
        else
            result += (char)(temp -10 + 'a');
    }
    for(int i=0;i<result.size();++i)
        cout << result[result.size()-1-i];
    system("pause");
    return 0;
}