# 14008: 【原4008】丁姐点外卖

### 题目描述

author: dzm 原OJ链接：https://acm.sjtu.edu.cn/OnlineJudge-old/problem/4008

## Sample Input

``````b
a
``````

## Sample Output

``````b
``````

## Sample Input

``````z
z
``````

## Sample Output

``````by
``````

## ligongzzz's solution

``````#include "iostream"
#include "cstring"
using namespace std;

int main() {
char a[200], b[200];
cin >> a >> b;
char ans[200] = { 0 };
for (int i = strlen(a)-1, j = strlen(b)-1,temp=0; i >= 0 || j >= 0 || temp != 0; i--, j--) {
int n1 = i < 0 ? 0 : a[i] - 'a';
int n2 = j < 0 ? 0 : b[j] - 'a';

if (n1 + n2 + temp > 25) {
ans[strlen(ans)] = 'a' + n1 + n2 + temp - 26;
temp = 1;
}
else {
ans[strlen(ans)] = 'a' + n1 + n2 + temp;
temp = 0;
}
}

//倒序输出
for (int i = strlen(ans) - 1; i >= 0; i--)
cout << ans[i];

return 0;
}
``````

## Neight99's solution

``````#include <cstring>
#include <iostream>

using namespace std;

int main() {
char a[110], b[110], c[220] = {'\0'}, cha, chb;
int aLen, bLen, Len, temp, carry = 0;

cin >> a >> b;
aLen = strlen(a);
bLen = strlen(b);
if (aLen > bLen) {
Len = aLen;
} else {
Len = bLen;
}

for (int i = 0; i < Len + 1; i++) {
if (i < aLen) {
cha = a[aLen - 1 - i];
} else {
cha = 'a';
}

if (i < bLen) {
chb = b[bLen - 1 - i];
} else {
chb = 'a';
}

temp = cha - 'a' + chb - 'a' + carry;
carry = 0;

if (temp >= 26) {
carry += 1;
temp -= 26;
}

c[Len - i] = temp + 'a';
}
c[Len + 1] = '\0';

if (c[0] == 'a') {
cout << c + 1;
} else {
cout << c;
}

return 0;
}
``````

## yyong119's solution

``````#include <iostream>
#include <cstring>
using namespace std;

int a[105],b[105],c[105];
char p[105],q[105];
int i, length;

int main() {

cin >> p >> q;
for (i = 0; i <= strlen(p) - 1; ++i) a[strlen(p) - i] = int(p[i] - 'a');
for (i = 0; i <= strlen(q) - 1; ++i) b[strlen(q) - i] = int(q[i] - 'a');
if (strlen(p) >= strlen(q)) length = strlen(p);
else length = strlen(q);
for (i = 1; i <= length; ++i){
c[i] += a[i] + b[i];
c[i + 1] += c[i] / 26; c[i] = c[i] % 26;
}
if (c[length + 1]) length++;
for (i = length; i >= 1; --i) cout << char('a' + c[i]);
return 0;
}
``````