fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <locale.h>
  4.  
  5. #define TAM 10
  6.  
  7. int difNumbers(int array[], int count) {
  8. int uniqValue[count];
  9. int n = 0;
  10.  
  11. for(int i = 0; i < count; i++) {
  12. unsigned char foundUnique = 0;
  13. for(int x = 0; x < n; x++) {
  14. if(uniqValue[x] == array[i]) {
  15. foundUnique = 1;
  16. break;
  17. }
  18. }
  19. if(!foundUnique) {
  20. uniqValue[n] = array[i];
  21. n++;
  22. }
  23. }
  24.  
  25. return n;
  26. }
  27.  
  28. int main() {
  29. setlocale(LC_ALL, "Portuguese");
  30. int vector[TAM], i;
  31.  
  32. for(i = 0; i < TAM; i++) {
  33. printf("[%d]:", i+1);
  34. scanf("%d", &vector[i]);
  35. }
  36. printf("%d", difNumbers(vector, TAM));
  37. return 0;
  38. }
  39.  
Success #stdin #stdout 0s 11064KB
stdin
1
1
1
1
1
2
2
2
2
2

stdout
[1]:[2]:[3]:[4]:[5]:[6]:[7]:[8]:[9]:[10]:2