File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+ int count = 0 ;
3+ void swap (int * x , int * y )
4+ {
5+ int temp ;
6+ temp = * x ;
7+ * x = * y ;
8+ * y = temp ;
9+ }
10+
11+ void quicksort (int * array ,int size ,int left ,int right )
12+ {
13+ count = count + 1 ;
14+ int location = right ;
15+ if (size > 1 )
16+ {
17+ for (int i = left ;i <=right ;i ++ )
18+ {
19+ if (array [right ]< array [i ])
20+ {
21+ for (int j = i ;j < right ;j ++ )
22+ {
23+ swap (& array [j ],& array [j + 1 ]);
24+ location -- ;
25+ }
26+ }
27+ }
28+ }
29+ }
30+ void main ()
31+ {
32+ int no ;
33+ printf ("Enter the number of elements in the array:" );
34+ scanf ("%d/n" ,& no );
35+ int a [no ],i ;
36+ for (i = 0 ;i < no ;i ++ )
37+ {
38+ printf ("Enter the %d Element:" ,i + 1 );
39+ scanf ("%d" ,& a [i ]);
40+ }
41+ quicksort (a ,no ,0 ,no - 1 );
42+ for (i = 0 ;i < no ;i ++ )
43+ {
44+ printf ("%d " ,a [i ]);
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments