AR15


TEST CASE 1 

INPUT
5 4
1 2 4 9 15
2 3 7 8
OUTPUT
1 2 2 3 4 7 8 9 15

TEST CASE 2 

INPUT
5 6
1 2 4 9 15
2 3 7 8 18 20
OUTPUT
1 2 2 3 4 7 8 9 15 18 20

#include <stdio.h>
void mergeArrays(int arr1[], int arr2[], int n1,int n2, int arr3[])
{
  int i,j;
  for(i=0;i<(n1+n2);i++)
  {
    if(i<n1)
      arr3[i]=arr1[i];
    else
      arr3[i]=arr2[i-n1];
    
  }
  for(i=0;i<n1+n2-1;i++) 
  { 
    for(j=0;j<n1+n2-1-i;j++) 
   { 
      if(arr3[j]>arr3[j+1]) 
    {  
         int temp=arr3[j]; 
      arr3[j]=arr3[j+1]; 
      arr3[j+1]=temp; 
        } 
   } 
  }//sorting completed
  for(i=0;i<n1+n2;i++)
    printf("%d ",arr3[i]);
}
int main() {
int n1, n2,i,j;
  scanf("%d %d", &n1, &n2);
  int arr1[n1], arr2[n2],arr3[n1+n2];
  
  for(i=0;i<n1;i++)
    scanf("%d",&arr1[i]);
  
  for(i=0;i<n2;i++)
    scanf("%d", &arr2[i]);
  
  mergeArrays(arr1,arr2,n1,n2,arr3);
 return 0;
}

Comments

  1. Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.
    Snowflake Training in Bangalore

    ReplyDelete
  2. Usually I never comment on blogs but your article is so convincing that I never stop myself to say something about it. You’re doing a great job Man learn
    Pega Training

    ReplyDelete
  3. output is correct. but its n ot 100% evoluvate
    only 75 persent evoluvate

    ReplyDelete

Post a Comment

Popular posts from this blog

AR1

SER12