解题思路:
注意事项:
参考代码:
#include <stdio.h>
void quick_sort(int num[], int low, int high)
{
int i, j, temp;
int tmp;
i = low;
j = high;
tmp = num[low];
if (i > j)
{
return;
}
while (i != j)
{
while (num[j] >= tmp && j > i)
{
j--;
}
while (num[i] <= tmp && j > i)
{
i++;
}
if (j > i)
{
temp = num[j];
num[j] = num[i];
num[i] = temp;
}
}
num[low] = num[i];
num[i] = tmp;
quick_sort(num, low, i - 1);
quick_sort(num, i + 1, high);
}
int main()
{
int a[100005];
int i,cnt=0,n;
scanf("%d", &n);
for (i = 0; i < n; i++)
{
scanf("%d", &a[i]);
cnt++;
}
quick_sort(a, 0, cnt-1);
for (i = 0; i < cnt; i++)
{
printf("%d ", a[i]);
}
return 0;
}
0.0分
0 人评分
WU-小九九 (C++代码)浏览:1684 |
IP判断 (C语言代码)浏览:762 |
C语言考试练习题_保留字母 (C语言代码)浏览:700 |
蛇行矩阵 (C语言代码)浏览:524 |
C语言程序设计教程(第三版)课后习题9.4 (C语言代码)浏览:664 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:553 |
关于float,double变量的几点说明浏览:1810 |
1074(纳闷了,答案错误,求指教)浏览:362 |
简单的a+b (C语言代码)浏览:353 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:472 |