http://acm.hdu.edu.cn/showproblem.php?pid=2100
直接模拟
#include<stdio.h> #include<string.h> int main() { char a[220],b[220]; int i,j,ans[440],lena,lenb; while(scanf("%s %s",a,b)!=EOF) { lena=strlen(a)-1; lenb=strlen(b)-1; for(i=0;i<440;i++)ans[i]=0; i=j=0; while(lena!=-1||lenb!=-1) { if(lena>=0) ans[i]+=a[lena--]-'A'; if(lenb>=0) ans[i]+=b[lenb--]-'A'; i++; } for(j=0;j<i;j++) if(ans[j]>25) { ans[j]-=26; ans[j+1]+=1; } while(ans[i]>25) { ans[i]-=26; ans[i+1]+=1; i++; } while(!ans[i])i--; if(i==-1) { printf("A "); continue; } for(;i>=0;i--) printf("%c",ans[i]+65); printf(" "); } }