The English description of this question is too redundant. Finally, after reading the question described in one sentence, I understood http://blog.163.com/kakarrot@yeah/blog/static/12011592520106241155854 /. In fact, it is to count the number of identical numbers in the same columns of two sequences and the number of identical numbers in different columns. Note that any element in the two columns cannot be reused if it has already been used.
Since there are only nine numbers, you only need to count the number of each number. First, calculate the statistics of the same numbers in the same column, that is, the number corresponding to the same number in the same column is reduced by one. Then count the number of nine numbers that appear in the two sequences. Each number is added with a smaller value that appears in the other two sequences. ViewCodeIt's easy.
# Include <stdio. h> # include <string. h> # include <stdlib. h> # define min (A, B) (a) <(B )? (A): (B) int main () {int s [1005], G [1005], n; int A [15], B [15], c [15]; int COUNT = 1; while (scanf ("% d", & N) {memset (C, 0, sizeof (c )); for (INT I = 0; I <n; I ++) {scanf ("% d", & S [I]); c [s [I] ++;} printf ("game % d: \ n", Count ++); While (1) {memcpy (a, c, sizeof (c); // assign the number of 1-9 counts in the Code to the array memset (B, 0, sizeof (B )); for (INT I = 0; I <n; I ++) {scanf ("% d", & G [I]); B [G [I] ++;} If (0 = G [0]) break; int x = 0, y = 0; For (INT I = 0; I <n; I ++) if (s [I] = G [I]) {A [s [I] --; B [s [I] --; X ++;} For (INT I = 1; I <= 9; I ++) Y + = min (A [I], B [I]); printf ("(% d, % d) \ n", x, y) ;}} return 0 ;}