标签:des style color java os strong io 数据
/*
中文题意:
中文翻译:
题目大意:将a集合中和b集合中相同的全部去除,留下所有和b集合不相同,并将其输出
解题思路:看懂题意,直接写下来就可以了。
难点详解:看清题意,避免不必要的PE错误。
关键点:排序和找到和B集合相同的数如何处理。
解题人:lingnichong
解题时间:2014/07/30 17:39:37 写
解题感受:
*/
3 3 1 2 3 1 4 7 3 7 2 5 8 2 3 4 5 6 7 8 0 0
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%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>//排序
for(i=0;i<m;i++)
scanf("%d",&b[i]);
sort(b,b+m);<span style="white-space:pre"> </span>//排序
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
if(a[i]==b[j])
{
t++;
a[i]=-1;//此处很重要
}
}
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;
}
HDU 2034 人见人爱A-B,布布扣,bubuko.com
标签:des style color java os strong io 数据
原文地址:http://blog.csdn.net/qq_16767427/article/details/38304185