Advertisement
Josif_tepe

Untitled

Feb 7th, 2022
871
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main()
  4. {
  5.     int n;
  6.     scanf("%d", &n);
  7.    
  8.     int niza[n];
  9.    
  10.     for(int i = 0; i < n; i++) {
  11.         scanf("%d", &niza[i]);
  12.     }
  13.     int visited[n]; // dali ovoj broj go imame ispecateno
  14.     for(int i = 0; i < n; i++) {
  15.         visited[i] = 0;
  16.     }
  17.     int frekvencija;
  18.     for(int i = 0; i < n; i++) {
  19.         if(visited[i] == 0) {
  20.             frekvencija = 1;
  21.             for(int j = i + 1; j < n; j++) {
  22.                 if(niza[i] == niza[j]) {
  23.                     frekvencija++;
  24.                     visited[j] = 1;
  25.                 }
  26.             }
  27.             printf("Frekvencija na %d = %d\n", niza[i], frekvencija);
  28.         }
  29.     }
  30.    
  31.    
  32.     return 0;
  33. }
  34. // 5 10 2 5 50 5 10 1 2 2
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement