快速排序
题目链接
先用快速排序对数组进行排序,对原数组进行遍历
如果满足该数满足他是遍历过程中最大的,而且该数和排好序的数组中对应的元素相等就说名他是主元
int comp(const void *a,const void *b)
{
return *(int *)a - *(int *)b;
}
qsort(arr_s,N,sizeof(int),comp)
快速排序
题目链接
先用快速排序对数组进行排序,对原数组进行遍历
如果满足该数满足他是遍历过程中最大的,而且该数和排好序的数组中对应的元素相等就说名他是主元
int comp(const void *a,const void *b)
{
return *(int *)a - *(int *)b;
}
qsort(arr_s,N,sizeof(int),comp)