#import <Foundation/Foundation.h>
int a[101],n;
void quickSort(int left,int right);
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
for (int i = 0; i<10; i++) {
scanf("%d",&a[i]);
}
quickSort(0, 9);
for (int i = 0; i < 10; i++) {
NSLog(@"tt == %d",a[i]);
}
}
return 0;
}
void quickSort(int left,int right)
{
if (left > right)
{
return;
}
int i,j,t,temp;
temp = a[left];
i = left;
j = right;
while (i!=j)
{
while (a[j] <= temp && j>i) {
j--;
}
while (a[i] >= temp &&i < j) {
i++;
}
if (i < j)
{
t = a[i];
a[i] = a[j];
a[j] = t;
}
}
a[left] = a[i];
a[i] = temp;
quickSort(left, i-1);
quickSort(i+1, right);
}
demo