http://acm.hdu.edu.cn/showproblem.php?pid=2100
#include <bits/stdc++.h>
using namespace std;
const int maxn = 300;
char a[3][maxn];
int len[2];
int main() {
while(~scanf("%s%s", a[0], a[1])) {
for(int t = 0; t < 2; t ++) {
strrev(a[t]);
len[t] = strlen(a[t]);
for(int j = len[t]; j < 300; j ++) {
a[t][j] = ‘A‘;
}
}
// cout << a[0] << endl << a[1] << endl;
int k = 0;
for(int i = 0; i < 300; i ++) {
int num = (a[0][i] - ‘A‘ + a[1][i] - ‘A‘ + k) % 26;
k = (a[0][i] - ‘A‘ + a[1][i] - ‘A‘ + k) / 26;
a[2][i] = ‘A‘ + num;
}
int pos = 0;
for(int i = 0; i < 300; i ++) {
if(a[2][i] != ‘A‘) {
pos = i;
}
}
for(int i = pos; i >= 0; i --) {
printf("%c", a[2][i]);
}
printf("\n");
}
return 0;
}
原文:https://www.cnblogs.com/zlrrrr/p/9452423.html