Skip to content

Commit b0dbbcc

Browse files
authored
Merge pull request zapellass123#479 from surajparui/main
Hacktoberfest 2022
2 parents 7d9258f + 2e98835 commit b0dbbcc

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

QUICKSORT.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
}

0 commit comments

Comments
 (0)