编辑代码

#include <stdio.h>

int main (void)
{

    int d, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10;
    int fir_sum, sec_sum, total;

    printf("Enter the first (single) digit: ");
    scanf("%1d", &d);
    printf("Enter the first group of five digits: ");
    scanf("%1d%1d%1d%1d%1d", &i1, &i2, &i3, &i4, &i5);
    printf("Enter the second group of five digits: ");
    scanf("%1d%1d%1d%1d%1d", &i6, &i7, &i8, &i9, &i10);

    fir_sum = d + i2 + i4 + i6 + i8 + i10;
    sec_sum = i1 + i3 + i5 +i7 + i9;
    total = 3 * fir_sum + sec_sum;

    printf("Check digit: %d\n", 9 - (total - 1) % 10);

    return 0;
}