1 #include <stdio.h> 2 void gg(int q[],int m,int n) 3 { 4 int a,b; 5 a = q[m]; 6 for (b=0;m<n;b++) 7 { 8 if (q[m] == a&&a<=q[n]) 9 { 10 n--; 11 12 } 13 else if (q[m] == a&&a>q[n]) 14 { 15 q[m] =q[n]; 16 q[n] = a; 17 m++; 18 19 } 20 else if (q[n] == a && a>q[m]) 21 { 22 m++; 23 } 24 else 25 { 26 q[n] = q[m]; 27 q[m] = a; 28 n--; 29 30 } 31 printf("%d**%d**%d**%d**%d**%d**%d****%d****%d****%d ",q[0],q[1],q[2],q[3],q[4],q[5],q[6],b,m,n); 32 33 } 34 printf ("%d %d ",m,n);printf ("start "); 35 36 gg(q,0,m-1); 37 gg(q,m+1,6); 38 39 } 40 main() 41 { 42 int c =0; 43 int q[7]={21,5,19,55,32,15,59}; 44 gg(q,0,6); 45 for(;c<7;c++) 46 printf ("%d ",q[c]); 47 }