我正在学习C并且讨论了排序问题.我写了一个comp()函数并用于qsort对数组进行排序int.现在,对于下一个任务,我需要从数组中删除重复项.
是否可以同时排序和删除重复项?
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int indexes[10] = { 0, 98, 45, 65, 45, 98, 78, 56, 65, 45 };
int comp(const void * elem1, const void * elem2) {
int f = *((int*) elem1);
int s = *((int*) elem2);
if (f > s) {
return 1;
}
if (f < s) {
return -1;
}
return 0;
}
void printIndexArray() {
int i = 0;
for (i = …Run Code Online (Sandbox Code Playgroud)