Code: #include<stdio.h> #include<conio.h> void quick(int *,int,int); void main() { int n,i,a[50],left,right; clrscr(); printf("enter the size of the array"); scanf("%d",&n); printf("enter the sequence"); for(i=0;i<=n-1;i++) { scanf("%d",&a[i]); } printf("the sorted array is:"); left=0; right=n-1; quick(&a[0],left,right); for(i=0;i<=n-1;i++) { printf("%d\t",a[i]); } getch(); } void quick(int *a,int left,int right) { int pivot,l_hold,r_hold,t; pivot=a[left]; l_hold=left; r_hold=right; while(left<right) { while(a[right]>=pivot && left<right) { right=right-1; } while(a[left]<=pivot && left<right) { left=left+1; } if(left!=right) { t=a[left]; a[left]=a[right]; a[right]=t; } } a[l_hold]=a[left]; a[left]=pivot; if(l_hold<left) quick(a,l_hold,left-1); if(r_hold>left) quick(a,left+1,r_hold); return; }
clrscr() and getch() again. Single letter variable names. No comments. My score for this post: 1/10 for effort. To get the other 9 you'll need to post considerably better code than this. Oh and void main() as well. Mark adjusted to 0/10.