题目比较孬,所以代码没加注释
#include <cmath>
#include <iomanip>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n;
cin >> n;
while (n--)
{
int a, b, c, d, e, f, g;
b = n;
cin >> a >> b;
int rem[100] = { 0 };
for (int i = 0; i < a; i++)
{
cin >> rem[i];
}
int ram[100] = { 0 };
for (int i = 0; i < b; i++)
{
cin >> ram[i];
}
d = 1;
int zaxiu[100];
e = 0;
for (int i = 0; i < a; i++)
{
c = 1;
for (int s = 0; s < b; s++)
{
if (rem[i] == ram[s])
{
c = 0;
}
}
if (c)
{
zaxiu[e]=rem[i];
e++;
d = 0;
}
}
sort(zaxiu, zaxiu + e);
if(d)
{
cout << "NULL"<< endl;
}
else
{
for (f = 0; f < e; f++)
{
if(f<e-1)cout << zaxiu[f] << " ";
if (f == e - 1)cout << zaxiu[f] << " " << endl;
}
}
}
return 0;
}
别问为什么数组名是zaxiu,我是月厨