fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define arr 10
  4. /*
  5. 5. Dado un vector de m laiListmentos, escriba un programa para obtener otro vector con los laiListmentos diferentes del primer vector extrayendo los laiListmentos repetidos.
  6. Ejemplo: Si el vector original es: 2, 3, 5, 3, 7, 8, 3, 3, 9 , entonces el nuevo será:
  7. 2, 3, 5, 7, 8, 9
  8. */
  9. short red(int num, int *ar);
  10. int main(void) {
  11. int laiList[arr]={0}, laiRes[arr]={0}, liAcc=0;
  12. short count=0;
  13. while(count<arr) {
  14. printf("Please input a number :");
  15. scanf("%d\n", &laiList[count]);
  16. count++;
  17. }
  18. count=0;
  19. while(count<arr) {
  20. if(red(laiList[count], laiList) == 0) {
  21. laiRes[liAcc] = laiList[count];
  22. liAcc++;
  23. }
  24. count++;
  25. }
  26. count=0;
  27. while(count<liAcc) {
  28. printf(" %d", laiRes[count]);
  29. count++;
  30. }
  31.  
  32. }
  33. short red(int num, int *ar) {
  34. short acc=0;
  35. short count=0;
  36. while(count<arr) {
  37. if(ar[count] == num)
  38. acc++;
  39. count++;
  40. }
  41. return acc;
  42. }
Success #stdin #stdout 0s 2012KB
stdin
1
2
3
4
5
6
7
8
9
0
stdout
Please input a number :Please input a number :Please input a number :Please input a number :Please input a number :Please input a number :Please input a number :Please input a number :Please input a number :Please input a number :