Advertisement
CoMoDoS

interclasare kk

Nov 12th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     printf("Hello world!\n");
  7.     int *a,*b,*c,i,j,n,aux,m,k;
  8.     scanf("%d",&n);
  9.     scanf("%d",&m);
  10.     a=(int*)malloc(sizeof(int)*n);
  11.     b=(int*)malloc(sizeof(int)*n);
  12.     c=(int*)malloc(sizeof(int)*n+m);
  13.     for ( i=0; i<n; i++ )
  14.         scanf("%d",a+i);
  15.     for ( i=0; i<m; i++ )
  16.         scanf("%d",a+i);
  17.     i=0;
  18.        for ( k=0; k<n; k++ )
  19.             for ( j=0; j<=m; j++ )
  20.                 if ( *(a+k)<*(b+j) )
  21.                 {
  22.                     *(c+i)=*(a+i);
  23.                     i++;
  24.                    // printf("%d ",*(c+i));
  25.                 }
  26.                 else
  27.                 {
  28.                     *(c+i)=*(b+j);
  29.                     i++;
  30.                     //printf("%d ",*(c+i));
  31.                 }
  32.     for ( k=0; k<i; k++ )
  33.         printf("%d  ",*(c+k));
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement