SORT13


TEST CASE 1 

INPUT
1
4 5
7 5 3 1
9 8 6 2 0
OUTPUT
9 8 7 6 5 3 2 1 0 

TEST CASE 2 

INPUT
2
5 6
8 5 3 1 0
15 12 10 7 4 2
4 2
8 6 3 0
7 1
OUTPUT
15 12 10 8 7 5 4 3 2 1 0 
8 7 6 3 1 0 

#include <stdio.h>
int main() {
  int t,N1,N2,arr[101],i,j,temp;
  scanf("%d",&t);
  while(t-->0)
  {
    scanf("%d %d", &N1, &N2);
    for (i=0; i<N1; i++)
     scanf("%d", &arr[i]);
    for (i=N1; i<N2+N1; i++)
        scanf("%d", &arr[i]);
    
    for (i=0 ; i<(N1+N2)-1; i++)
  {
    for (j=0 ; j<(N1+N2)-i-1; j++)
    {
      if (arr[j] < arr[j+1])
      {
        temp=arr[j];
        arr[j]=arr[j+1];
        arr[j+1]=temp;
      }
    }
  }
   for(i=0;i<(N1+N2);i++)
     printf("%d ",arr[i]);
    printf("\n");
  
  }
    
 return 0;
}

Comments

Popular posts from this blog

AR1

SER12

AR15