ArfIsAToe

correction exercice 7 ama hedhi s7i7a xd

Feb 2nd, 2021 (edited)
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #define TAILLE_MAX 1000 // La taille maximale
  3. int main()
  4. {
  5. int tab[TAILLE_MAX], freq[TAILLE_MAX];
  6. int N, i, j, count;
  7. /* Saisir la taille actuelle du tableau < TAILLE_MAX */
  8. printf("Saisir le nombre d'éléments : ");
  9. scanf("%d", &N);
  10.  
  11. /* Saisir les éléments du tableau tab */
  12. for(i=0; i<N; i++)
  13. {
  14. printf("Elément %d ", i+1);
  15. scanf("%d", &tab[i]);
  16. }
  17. /* Trouver la fréquence de chaque élément */
  18. for (int a=0;a<N;a++)
  19. {
  20.     freq[tab[a]]=0;
  21. }
  22. for (int a=0;a<N;a++)
  23. {
  24.     freq[tab[a]]++;
  25. }
  26. /* afficher tous les éléments uniques du tableau */
  27. for(i=0; i<N; i++)
  28. {
  29. if(freq[tab[i]] == 1)
  30. {
  31. printf("%d ", tab[i]);
  32. }
  33. }
  34.  
  35. }
  36.  
Add Comment
Please, Sign In to add comment