/*
Question:
Chinese Translation:
Remove all identical items in set a and Set B, leave all items different from Set B, and output them.
Solution: understand the meaning of the question and simply write it down.
Difficulties: Check the meaning of the question to avoid unnecessary PE errors.
Key point: how to sort and find the same number of B sets.
Problem solving person: lingnichong
Solution time: 17:39:37
Experience in solving problems:
*/
People love A-B
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 43463 accepted submission (s): 12224
The person who participated in the Problem description last month's competition must remember one of the simplest questions: {A} + {B}. The question is the union of the two sets, today, our A-B calculates the difference between the two sets, that is, the subtraction operation of the Set. (Of course, we all know the definition of a set, that is, there will not be two identical elements in the same set. Here, I would like to remind you)
It's easy, right?
Each input group occupies one row. Each row starts with two integers, n (0 <= n <= 100) and M (0 <= m <= 100 ), indicates the number of elements of set a and Set B respectively, followed by N + M elements. The first n elements belong to set a, and the rest belong to Set B. each element is an integer not greater than the int value range. Each element is separated by a space.
If n = 0 and m = 0, the input ends without processing.
Output outputs a line of data for each group of data, indicating the results of the A-B, if the results are empty set, the output "null", otherwise the output results from small to large, to simplify the problem, each element is followed by a space.
Sample Input
3 3 1 2 3 1 4 73 7 2 5 8 2 3 4 5 6 7 8 0 0
Sample output
2 3 NULL
# Include <stdio. h ># include <algorithm> using namespace STD; int A [110] = {0}, B [110] = {0}; int main () {int n, m; while (scanf ("% d", & N, & M), N + M) {int I, j, T = 0; for (I = 0; I <n; I ++) scanf ("% d", & A [I]); sort (A, A + n); <span style = "white-space: pre "> </span> // sort for (I = 0; I <m; I ++) scanf (" % d ", & B [I]); sort (B, B + M); <span style = "white-space: pre"> </span> // sort for (I = 0; I <N; I ++) {for (j = 0; j <m; j ++) if (a [I] = B [J]) {T ++; A [I] =-1; // important here} If (t = N) printf ("null \ n"); else {for (I = 0; I <n; I ++) if (a [I]> = 0) printf ("% d", a [I]); printf ("\ n") ;}} return 0 ;}