看完后还以为好简单,做完后2,5点一直没过,参考博客https://blog.csdn.net/qq_44352065/article/details/104168192才知道,b不足位要补0😂😂😂。
#include<bits/stdc++.h>
using namespace std;
string t[13]={"0","1","2","3","4","5","6","7","8","9","J","Q","K"};
string res="";
int main(){
string a,b;
cin>>a>>b;
int len=a.size()-b.size();
if(len>0)
for(int i=0;i<len;i++)b="0"+b;
int c=1,idx=b.size()-1;
for(int i=a.size()-1;i>=0;i--,idx--){
if(c%2==1){//奇数
res=t[(a[i]+b[idx]-2*'0')%13]+res;
}else{
int temp=b[idx]-a[i];
if(temp<0)temp+=10;
res=t[temp]+res;
}
c++;
}
for(int i=idx;i>=0;i--)res=b[i]+res;
cout<<res;
// idx=0;
// while(res[idx]=='0')idx++;
// if(idx==res.size())cout<<"0";
// for(int i=idx;i<res.size();i++)cout<<res[i];
return 0;
}