1481 merge Columns

Source: Internet
Author: User

 

Description

Merge Columns

Two non-descending sequence numbers A and B are given. The value of an element in a series is int, and the number of elements cannot exceed 1,000. Combine two sorted series into a non-ascending series output.

 

Input

The input has 3 m + 1 rows. The number of groups of the first behavior test data is M. The following 3 m is the test data of the M group. The first row of the test data contains the numbers A and B, indicating that the next two rows have the numbers A and B respectively, next, Series a B occupies two rows, and the elements in each series are separated by spaces.

Output

The output contains m rows, which correspond to the input m-group test data. The combined non-ascending sequence is output, and elements are separated by spaces.

 

 

Classic Problems

#include<stdio.h>main(){int te,number;int temp1,temp2,temp;int i,j,k;int a[1000],b[1000],c[2000];scanf("%d",&number);for (te=1;te<=number;te++){    k=0;scanf("%d %d",&temp1,&temp2);for(i=0;i<temp1;i++)scanf("%d",&a[i]);for(i=0;i<temp2;i++)scanf("%d",&b[i]);for(i=0;i<temp1;i++){c[k]=a[i];k++;}for(i=0;i<temp2;i++){c[k]=b[i];k++;}for(i=0;i<temp1+temp2;i++)   for(j=i+1;j<temp1+temp2;j++)   {       if(c[i]>c[j])   {   temp=c[j];        c[j]=c[i];        c[i]=temp;   }   }for(i=temp1+temp2-1;i>=1;i--)        printf("%d ",c[i]);printf("%d\n",c[0]);}}

 

Related Article

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.