Advertisement
Mixilino

Cobi

Apr 18th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void unijaElemenata(int niz1[], int niz2[], int niz3[], int n, int * brojElNovog) {
  4.     *brojElNovog = 0;
  5.     for (int i = 0; i < n; i++)
  6.     {
  7.         for (int j = 0; j < n; j++)
  8.         {
  9.             if (niz1[i] == niz2[j]) {
  10.                 niz3[*brojElNovog] = niz1[i];
  11.                 (*brojElNovog)++;
  12.             }
  13.         }
  14.     }
  15. }
  16. void stampaj(int niz[], int n) {
  17.     for (int i = 0; i < n; i++)
  18.     {
  19.         printf("%d\t", niz[i]);
  20.     }
  21. }
  22.  
  23. int main(void) {
  24.     int niz1[10] = { 1,3,5,2,9,3,6,8,9,7 };
  25.     int niz2[10] = { 13,23,12,2,9,5,32,8,12,15 };
  26.     int nizU[20];
  27.     int n = 10, brojElNovog;
  28.     unijaElemenata(niz1, niz2, nizU, n, &brojElNovog);
  29.     stampaj(nizU, brojElNovog);
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement