# Zhejiang University pat class B 1048 test points 4 and 5 cannot pass, solution

2022-02-04 16:50:20

As shown in the figure , At present, the test output of the examples I use is correct , Solve what examples will make mistakes or how to modify them to pass the test points 4 and 5, thank you ！

``#include<stdio.h>char A[100],B[100];int max(int a,int b){    if (a>=b)        return a;    else        return b;}void zero_padding(int len_a,int len_b)// The rule entered is len_a>len_b{    int num_0,i;    if (len_a>len_b)// Yes B Zero compensation     {        num_0 = len_a-len_b;        for (i=len_b-1;i>=0;i--)            B[i+num_0] = B[i];        for (i=0;i<num_0;i++)            B[i] = '0';    }    else // Yes a Zero compensation     {        num_0 = len_b-len_a;        for (i=len_a-1;i>=0;i--)            A[i+num_0] = A[i];        for (i=0;i<num_0;i++)            A[i] = '0';    }}int main(){    int i,len,temp;    char a;    int lenA = 0;    int lenB = 0;    for (i=0;i<100;i++)    {        scanf("%c",&a);        if (a==' ')            break;        A[i] = a;        lenA++;    }    for (i=0;i<100;i++)    {        scanf("%c",&a);        if (a=='\n')            break;        B[i] = a;        lenB++;    }    if (lenA!=lenB)// The length is not the same , High zero filling operation         zero_padding(lenA,lenB);    len = max(lenA,lenB);    int odd_even;// If it is equal to 1, It is odd. ;0 Even digit     if (len%2==0)// Judge who comes first         odd_even = 0;    else        odd_even = 1;    for (i=0;i<len;i++)    {        if (odd_even==1)// Odd number         {            temp = (B[i]+A[i]-48*2)%13;            switch (temp){                case 10: temp = 'J'-48;break;                case 11: temp = 'Q'-48;break;                case 12: temp = 'K'-48;break;                default: break;//J  representative  10、Q  representative  11、K  representative  12            }            printf("%c",(temp+48));            odd_even = 0;        }        else        {            temp = B[i]-A[i];            if (temp<0)                temp += 10;            printf("%d",temp);            odd_even = 1;        }    }    return 0;}``