Advertisement
Josif_tepe

Untitled

Jun 11th, 2024
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4. #include <math.h>
  5.  
  6. int funkcija(int *niza1, int n1, int *niza2, int n2) {
  7.     int sz;
  8.     if(n1 < n2) {
  9.         sz = n1;
  10.     }
  11.     else {
  12.         sz = n2;
  13.     }
  14.  
  15.     for(int i = 0; i < sz; i++) {
  16.         if(niza1[i] == niza2[i]) {
  17.             niza1[i] = -1;
  18.         }
  19.     }
  20.  
  21. }
  22. int main(int argc, char * argv[]) {
  23.     int n1;
  24.     scanf("%d", &n1);
  25.     int niza1[n1];
  26.     for(int i = 0; i < n1; i++) {
  27.         scanf("%d", &niza1[i]);
  28.     }
  29.     int n2;
  30.     scanf("%d", &n2);
  31.     int niza2[n2];
  32.     for(int i = 0; i < n2; i++) {
  33.         scanf("%d", &niza2[i]);
  34.     }
  35.     int result = funkcija(niza1, n1, niza2, n2);
  36.  
  37.     for(int i = 0; i < n1; i++) {
  38.         if(niza1[i] != -1) {
  39.             printf("%d ", niza1[i]);
  40.         }
  41.     }
  42.    
  43. }
  44.  
  45.  
  46. /*
  47. 7
  48. 7 2 15 0 3 4 5
  49. 7
  50. 6 1 15 1 13 4 6
  51. **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement