fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5. int N, repetidos = 0;
  6. printf ("Entre com N: ");
  7. scanf ("%d", &N);
  8. int *v1 = malloc(N * sizeof (int));
  9. int *flag = malloc(N * sizeof (int));
  10. int cont = 0;
  11. for (int i = 0; i < N; i++) {
  12. int valor = 0;
  13. scanf ("%d", &valor);
  14. int achou = 0;
  15. for (int j = 0; j < cont; j++) {
  16. if (valor == v1[j]) {
  17. flag[j] = 1;
  18. achou = 1;
  19. break;
  20. }
  21. }
  22. if (!achou) {
  23. v1[cont] = valor;
  24. flag[cont++] = 0;
  25. }
  26. }
  27. for (int i = 0; i < cont; i++) {
  28. repetidos += flag[i];
  29. }
  30. if (repetidos > 0) {
  31. printf ("\n%d repetidos", repetidos);
  32. }
  33. }
Success #stdin #stdout 0s 2304KB
stdin
4
1
1
1
1
stdout
Entre com N: 
1 repetidos