HDU2034 人见人爱 A - B

2019-05-17

09:37:46

加油,加油 !!!

结果要从小到大输出

NULL后面没有空格

m && n == 0才结束

注意:看题仔细,罚时很严重

#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int main()
{
    int n, m;
    int i, j;
    int x;
    while(~scanf("%d %d", &n, &m))
    {
        if (n == 0 && m == 0)
        {
            return 0;
        }
        a.clear();
        for (i = 0; i < n; i++)
        {
            scanf ("%d", &x);
            a.push_back(x);
        }
        for (j = 0; j < m; j++)
        {
            scanf("%d", &x);
            if(find(a.begin(), a.end(), x) != a.end())
            {
                a.erase(find(a.begin(), a.end(), x));
            }
        }
        if(a.empty())
        {
            cout << "NULL" << endl;
            continue;
        }
        sort(a.begin(),a.end());
        for(i = 0; i < a.size(); i++)
        {
            cout << a[i] << " ";
        }
        cout << endl;
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/Artimis-fightting/p/10879662.html