题意写的根本就不清楚啊,要把AB短的地方都当做0处理才对
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<vector>
#include<map>
using namespace std;
#define _for(i,lo,hi) for(int i=(lo);i<(hi);i++)
int digit(char c){
if(c>='0'&&c<='9')return c-'0';
else if(c=='J')return 10;
else if(c=='Q')return 11;
else if(c=='K')return 12;
}
char num(int x){
if(x>=0&&x<=9)return '0'+x;
else if(x==10)return 'J';
else if(x==11)return 'Q';
else return 'K';
}
int main(){
//freopen("d:\\input.txt","r",stdin);
string A,B;
cin>>A>>B;
reverse(A.begin(),A.end());reverse(B.begin(),B.end());
while(B.size()<A.size())B+="0";
int flag=true;//true表示奇数位
_for(i,0,min(B.size(),A.size())){
if(flag){
B[i]=num((digit(B[i])+digit(A[i]))%13);
}else{
B[i]=num((digit(B[i])+10-digit(A[i]))%10);
}
flag=!flag;
}
int i=B.size()-1;
while(i>=0&&B[i]=='0')i--;
while(i>=0)cout<<B[i--];
return 0;
}