c語言數組去重算法
# include & ltstdio.h & gt# include & ltmalloc.h & gt使用命名空間stdbool isRepeat(int *arr,int len,int elem){ for(int I = 0;我& ltleni++) if(arr[i]==elem)返回true返回false} int* delRepeat(int *arr,int len){ int * tar =(int *)malloc(sizeof(int));內部溫度;無符號字符I;無符號字符j = 0;tar[j]= arr[0];for(I = 1;我& ltleni++) { if(!isRepeat(tar,j+1,arr[I]){ tar =(int *)realloc(tar,sizeof(int)*(j+2));tar[++ j]= arr[I];} }返回tar} int main() { int a[5] = {1,2,2,3,3 };int *b = delRepeat(a,5);返回0;}