ime_2/Exercícios/10 - Ordenação: Algoritmos elementares/set.c

12 lines
313 B
C
Raw Permalink Normal View History

2023-02-12 00:42:14 +01:00
#include <malloc.h>
int *set(int *orderedArray, int size, int *count) {
int i, *result = malloc(size * sizeof(int));
*result = *orderedArray;
for (i = *count = 1; i < size; i++)
if (orderedArray[i] != orderedArray[i - 1])
result[*count++] = orderedArray[i];
return result;
}