幾A幾B

 avatar
user_6817964
c_cpp
2 years ago
543 B
2
Indexable
Never
#include <stdio.h> // printf
int main()
{
    int n, m, n_a[4],m_a[4], x = 0, y = 0, k = 1000;
    scanf_s("%d%d", &n, &m);
    for (int i = 0; i < 4; i++) {
        n_a[i] = n / k;
        m_a[i] = m / k;
        n = n - (n / k) * k;
        m = m - (m / k) * k;
        k = k / 10;
    }
    for (int i = 0; i < 4; i++) {
        if (n_a[i] == m_a[i])
            x++;
        else
            for (int j = 0; j < 4; j++)
                if (n_a[i] == m_a[j])
                    y++;
    }
    printf("%dA%dB", x, y);
}