diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2006-06-29 16:07:01 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2006-06-29 16:07:01 +0000 |
commit | 917e891d06e16516fe90e286f184062e6b7409fe (patch) | |
tree | dd5ea25f036abdb00a7b35b0caeac5e75cae82ed /test/c/qsort.c | |
parent | a29dfda37f01871db5b8e40d5312d08fc0ee53e3 (diff) | |
download | compcert-917e891d06e16516fe90e286f184062e6b7409fe.tar.gz compcert-917e891d06e16516fe90e286f184062e6b7409fe.zip |
Version C des tests Cminor
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@40 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'test/c/qsort.c')
-rw-r--r-- | test/c/qsort.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/c/qsort.c b/test/c/qsort.c new file mode 100644 index 00000000..9f8e5b18 --- /dev/null +++ b/test/c/qsort.c @@ -0,0 +1,16 @@ +void quicksort(int lo, int hi, int base[]) +{ + int i,j; + int pivot,temp; + + if (lo<hi) { + for (i=lo,j=hi,pivot=base[hi];i<j;) { + while (i<hi && base[i]<=pivot) i++; + while (j>lo && base[j]>=pivot) j--; + if (i<j) { temp=base[i]; base[i]=base[j]; base[j]=temp; } + } + temp=base[i]; base[i]=base[hi]; base[hi]=temp; + quicksort(lo,i-1,base); quicksort(i+1,hi,base); + } +} + |