int cmp(const void* a,const void* b){
return *(int*)a-*(int*)b;
}
int findContentChildren(int* g, int gSize, int* s, int sSize) {
qsort(g,gSize,sizeof(int),cmp);
qsort(s,sSize,sizeof(int),cmp);
int i=0,j=0,n=0;
while(i<gSize && j<sSize){
if(g[i]<=s[j]){
i++;
j++;
n++;
}else{
j++;
}
}
return n;
}
结果:
标签:分发,const,gSize,int,void,455,饼干,sizeof,cmp From: https://www.cnblogs.com/llllmz/p/18064230