void duplicateZeros(int* arr, int arrSize) {
int* temp=(int*)malloc(sizeof(int)*arrSize);
int head=0,index=0;
while(head<arrSize && index<arrSize){
temp[head++]=arr[index++];
if(arr[index-1]==0){
if(head==arrSize) break;
temp[head++]=0;
}
}
for(int i=0;i<arrSize;i++) arr[i]=temp[i];
free(temp);
}
结果:
标签:index,head,int,1089,arrSize,复写 From: https://www.cnblogs.com/llllmz/p/18071787