#include <iostream> #include <vector> #include<algorithm> //包含sort函数 using namespace std; int main() { int n, m; int a[101], b[101]; bool c[101]; while (cin >> n >> m && (m || n)) { int count = 0; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { c[i] = true; } for (int j = 1; j <= m; j++) cin >> b[j]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (a[i] == b[j]) { c[i] = false; count++; } } } if (n == 0 && m == 0) break; if (n == 0) { cout << "NULL" << endl; continue; } if (m == 0 || count==0) { for (int i = 1; i < n; i++) cout << a[i]<<" "; cout << a[n] << " " << endl; continue; } for (int i = 1; i <= n; i++) { if (c[i]==true) { cout << a[i] << " "; } } cout << endl; } }
不明白为什么错误