1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| _func _void quickSort{ _para{ _int [] s; _int l _int r; }; _var{ _int i; }; _pro{ _if (l< r){ i = l; j = r; x = s[l]; _while (i < j){ _while(i < j _and s[j]>= x){ j=j-1; }; _if(i < j){ s[i] = s[j]; i=i+1; }{}; _while(i < j _and s[i]< x){ i=i+1; }; _if(i < j){ s[j] = s[i]; j=j-1; }{}; }; s[i] = x; quickSort(s, l, i - 1); quickSort(s, i + 1, r); }{}; }; };
_main{ _const{ _int printi 0;#print int _int prints 1;#print string }; _var{ _int [] array; _int len,k; }; _pro{ array[]=[34,65,12,43,67,5,78,10,3,70]; len = 10;#len=sizeof(array)/sizeof(int); print(prints,"The orginal arrayare:\n"); _for(k=0;k<len;k=k+1){ print(printi,array[k]); print(prints,","); }; print(prints,"\n"); quickSort(array,0,len-1); print(prints,"The sorted arrayare:\n"); _for(k=0;k<len;k=k+1){ print(printi,array[k]); print(prints,","); }; print(prints,"\n"); return 0; }; };
|