#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void quicksort(int* p, int len) {
if (len <= 1)
return;
int start, end, value;
start = 0;
end = len - 1;
value = p[0];
while (start < end) {
while (start < end) {
if (p[end] < value) {
p[start] = p[end];
start++;
break;
}
else
end--;
}
while (start<end) {
if (p[start]>value) {
p[end] = p[start];
end--;
break;
}
else
start++;
}
}
p[start] = value;
quicksort(p, start);
quicksort(p+start+1, len-start-1);
}
int main()
{
int a[20];
int n, i, j;
scanf("%d", &n);
for (i = 0; i < n; i++)
{
scanf("%d", &a[i]);
}
quicksort(a, n);
for (i = 0; i < n; i++)
{
printf("%d\n", a[i]);
}
return 0;
}
#include <stdio.h>
void quicksort(int* p, int len) {
if (len <= 1)
return;
int start, end, value;
start = 0;
end = len - 1;
value = p[0];
while (start < end) {
while (start < end) {
if (p[end] < value) {
p[start] = p[end];
start++;
break;
}
else
end--;
}
while (start<end) {
if (p[start]>value) {
p[end] = p[start];
end--;
break;
}
else
start++;
}
}
p[start] = value;
quicksort(p, start);
quicksort(p+start+1, len-start-1);
}
int main()
{
int a[20];
int n, i, j;
scanf("%d", &n);
for (i = 0; i < n; i++)
{
scanf("%d", &a[i]);
}
quicksort(a, n);
for (i = 0; i < n; i++)
{
printf("%d\n", a[i]);
}
return 0;
}