HDU 2034 A-B

#include


#include
#include
using namespace std;
int main()
{
 //freopen("h2034.txt","r",stdin);
 int n,m,i,temp;
 set a;
 while(1)
 {
  scanf("%d%d",&n,&m);
  if(0==n&&0==m)
   return 0;


  a.clear();
  for(i=1;i<=n;i++)
  {
   scanf("%d",&temp);
   a.insert(temp);
  }
  for(i=1;i<=m;i++)
  {
   scanf("%d",&temp);
   a.erase(temp);
  }
  if(a.empty())
   printf("NULL\n");
  else
  {
   set::iterator it;
   for(it=a.begin();it!=a.end();it++)
    printf("%d ",* it);
   printf("\n");
  }
 }
 return 0;

}


2


#include
#include
#include
using namespace std;
int main()
{
 int n,m,i,j,count;
 int a[101],b[101],c[101];
 memset(a,true,sizeof(a));
 memset(b,true,sizeof(b));
 
 while(scanf("%d%d",&n,&m)!=EOF)
 {
  if(m==0 && n ==0)  break;//m,n都为0的情况
  
  for(i = 0; i < n; i ++)
  cin>>a[i];
  for(j = 0; j < m; j ++)
  cin>>b[j];
  //赋初值
  int k=0,d=0;
  for(i = 0; i < n; i++)
  {
   count = 0;
   int g=a[i];
   for(j = 0; j < m; j++)
   {
    if(b[j] == g)
    count++;
   }
   if(count == 0)
   {
    c[k] = a[i];
    k++;
    d++;
   }
  }
  if(d==0)
  cout<<"NULL";
  else
  {
   sort(c,c+d);
   for(i = 0 ; i < d; i++)
    cout<    
  }
  cout<  }
 //while(1);
 return 0;
}

你可能感兴趣的:(ACM)