zoukankan      html  css  js  c++  java
  • 1412 {A} + {B}

    Problem Description
    给你两个集合,要求{A} + {B}.
    注:同一个集合中不会有两个相同的元素.
     
    Input
    每组输入数据分为三行,第一行有两个数字n,m(0<n,m<=10000),分别表示集合A和集合B的元素个数.后两行分别表示集合A和集合B.每个元素为不超出int范围的整数,每个元素之间有一个空格隔开.
     
    Output
    针对每组数据输出一行数据,表示合并后的集合,要求从小到大输出,每个元素之间有一个空格隔开.
     
    Sample Input
    1 2
    1
    2 3
    1 2
    1
    1 2
     
    Sample Output
    1 2 3
    1 2

     

     1 #include <iostream>
     2 #include <algorithm>
     3 #include <stdio.h>
     4 #include <math.h>
     5 #include <string.h>
     6 #include <time.h>
     7 using namespace std;
     8 int a[10005],b[10005],c[100005];
     9 int main()
    10 {
    11     int n,m,i,j,k,t;
    12     while(cin>>n>>m)
    13     {
    14         for(i=0;i<n;i++)
    15         {
    16             cin>>a[i];
    17             c[i]=a[i];
    18         }
    19         k=n;
    20         for(j=0;j<m;j++)
    21         {
    22             cin>>b[i];
    23             c[k]=b[i];
    24             k++;
    25         }
    26         sort(c,c+k);
    27         cout<<c[0];
    28         for(i=1;i<k-1;i++)
    29         if(c[i]!=c[i-1])
    30         cout<<" "<<c[i];
    31         if(c[k-1]!=c[k-2])
    32         cout<<" "<<c[k-1]<<endl;
    33         else
    34         cout<<endl;
    35     }
    36     return 0;
    37 }
    View Code
  • 相关阅读:
    gdal source code c++ make windows
    libjpeg安装和使用
    window 安装gdal和python
    gdal和python在windows上的安装
    将博客搬至CSDN
    ue4 Worldmachine 结合使用
    织梦学习
    前端 css html js javascript jquery
    jquery 表单验证插件
    gif动图生成
  • 原文地址:https://www.cnblogs.com/wang-ya-wei/p/5258623.html
Copyright © 2011-2022 走看看