Advertisement
Josif_tepe

Untitled

Aug 24th, 2021
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4. int main() {
  5.     int n;
  6.     scanf("%d", &n);
  7.    
  8.     int niza[n];
  9.     for(int i = 0; i < n; i++) {
  10.         scanf("%d", &niza[i]);
  11.     }
  12.     int nova_niza[n];
  13.     int m = 0;
  14.     int se_pojavil;
  15.     for(int i = 0; i < n; i++) {
  16.         se_pojavil = 0;
  17.         for(int k = 0; k < m; k++) {
  18.             if(nova_niza[k] == niza[i]) {
  19.                 se_pojavil = 1;
  20.             }
  21.         }
  22.         if(se_pojavil == 0) {
  23.             nova_niza[m] = niza[i];
  24.             m++;
  25.         }
  26.     }
  27.     for(int i = 0; i < m; i++) {
  28.         printf("%d ", nova_niza[i]);
  29.     }
  30. }
  31.  
  32.  
  33. // 1 2 3 4 5
  34. // 1 3 6 10 15
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement