69,382
社区成员
发帖
与我相关
我的任务
分享
int * ClearArray(const int * SourceArray, const int size, int & ResultArrSize)
{
int * ReslutArray = (int *)malloc(sizeof(int) * size);
*ReslutArray = *SourceArray;
ResultArrSize = 1;
for(int index = 1; index < size; index++) {
if (*(SourceArray + index) > *(SourceArray + index - 1)) { //有序数组判断是否出现不同值
*(ReslutArray + ResultArrSize) = *(SourceArray + index);
ResultArrSize++;
}
}
return ReslutArray;
}
void main()
{
int a[10] = {1,1,2,2,2,3,4,5,6,7};
int ResultArrSize;
int * ReslutArray = del(a, 10, ResultArrSize);
for(int i = 0; i < ResultArrSize; i++) {
printf("%d", ReslutArray[i]);
}
free(ReslutArray); //!
return;
}