C ++ click -- {A} + {B} to add A set

Source: Internet
Author: User

C ++ click -- {A} + {B} to add A set
Problem Description gives you two sets. {A} + {B} is required }.
Note: there will not be two identical elements in the same set. Input each group of Input data is divided into three rows, the first row has two numbers n, m (0 Output outputs a row of data for each group of data, indicating the merged set, which must be Output from small to large. Each element is separated by a space. Sample Input

1 212 31 211 2
Sample Output
1 2 31 2

 

 

/* Copyright (c) 2014, School of Computer Science, Yantai University * All rights reserved. * file name: test. cpp * Prepared by: Chen Danni * completion date: May 24, 2015 * version No.: v1.0 */# include
 
  
Using namespace std; int main () {int n, m, I, j, a [20002], B [20002], t; while (cin> n> m) {for (I = 0; I
  
   
> A [I]; for (I = 0; I
   
    
A [j + 1]) {t = a [j]; a [j] = a [j + 1]; a [j + 1] = t ;} B [0] = a [0]; j = 0; for (I = 1; I
    
     

 

Experience: I have been doing this question for a long time. If anyone has a better solution, please let me know. Thank you! Continue to work!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.