#include<stdio.h>
#include<string.h>
int main(){
char astr[101],bstr[101],str[101];
scanf("%s %s",astr,bstr);
int alen=strlen(astr),blen=strlen(bstr);
int i=0,j=0,k=0,odd,tmp;
for(;i<blen-alen;i++){
str[k++]=bstr[i];
}
if((alen&1)!=(j&1)) odd=1;
else odd=0;
for(;j<alen-blen;j++){
if(odd){
str[k++]=astr[j];
odd=0;
}
else{
if(astr[j]=='0') str[k++]='0';
else str[k++]=10-(astr[j]-'0')+'0';
odd=1;
}
}
if((blen&1)!=(i&1)) odd=1;
else odd=0;
for(;i<blen;i++,j++){
if(odd){
tmp=astr[j]-'0'+bstr[i]-'0';
tmp%=13;
switch(tmp){
case 10:str[k++]='J';break;
case 11:str[k++]='Q';break;
case 12:str[k++]='K';break;
default:str[k++]=tmp+'0';break;
}
odd=0;
}else{
tmp=bstr[i]-astr[j];
if(tmp<0) tmp+=10;
str[k++]=tmp+'0';
odd=1;
}
}
str[k++]='\0';
puts(str);
return 0;
}
PAT(Basic Level)_1048_数字加密
最新推荐文章于 2023-06-27 14:31:28 发布