Advertisement
lukasd

zadanie 2 zestaw 11(do poprawy)

Dec 17th, 2017
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. void bug(int a[], int n, int b[],int g,int c)
  2. {
  3.     int r = 0;
  4.     int *ptr=&a[n];
  5.     for (int i = 0; i < n;i++)
  6.     {
  7.         a[i] = rand() % 90 + 10;
  8.         printf("%d ", a[i]);
  9.     }
  10.     printf("\n");
  11.     for (int i = 0; i < g; i++)
  12.     {
  13.         b[i] = rand() % 90 + 10;
  14.         printf("%d ", a[i]);
  15.     }
  16.     printf("\n");
  17.     *a = (int)realloc(a, sizeof(int)*n+g);
  18.     for (int i = 0; i < c; i++)
  19.     {
  20.         a[i]=a[i];
  21.     }
  22.     for (int i = c; i < (c+g); i++)
  23.     {
  24.         a[i] = b[r++];
  25.     }
  26.     for (int i = (c+g); i < (n + g); i++)
  27.     {
  28.         a[i]=a[n+g--];
  29.     }
  30.     for (int i = 0; i < (n + g); i++)
  31.     {
  32.         printf("%d ", a[i]);
  33.     }
  34. }
  35. void kolos1()
  36. {
  37.     int c;
  38.     int g;
  39.     int *a;
  40.     int b[5];
  41.     int n=20;
  42.     a = (int*)malloc(sizeof(int)*n);
  43.     bug(a, n,b,5,10);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement