122. 1A2B3C

 avatar
user_6817964
c_cpp
2 years ago
814 B
2
Indexable
Never
void _A_B_C(int num1, int num2);
void _A_B_C(int num1, int num2) {
    int x[5], y[5];
    for (int i = 1; i <= 4; i++) {
        x[i] = num1 % 10;
        y[i] = num2 % 10;
        num1 /= 10;
        num2 /= 10;
    }

    int A = 0, B = 0, C = 0;
    for (int i = 1; i <= 4; i++) {
        if (x[i] == y[i]) {
            A++;
        }
        else {
            int flag = 1;
            for (int j = 1; j <= 4; j++) {
                if (x[i] == y[j]) {
                    B++;
                    flag = 0;
                }
            }
            if (flag == 1) {
                C++;
            }
        }
    }

    printf("%dA%dB%dC", A, B, 2 * C);
}

int main() {
    int num1, num2;
    scanf("%d %d", &num1, &num2);
    _A_B_C(num1, num2);

    return 0;
}