forked from zapellass123/OpenEmailGenerator
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQUICKSORT.c
46 lines (45 loc) · 919 Bytes
/
QUICKSORT.c
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
#include<stdio.h>
int count=0;
void swap(int *x, int *y)
{
int temp;
temp = *x;
*x = *y;
*y = temp;
}
void quicksort(int *array,int size,int left,int right)
{
count=count+1;
int location=right;
if(size>1)
{
for(int i=left;i<=right;i++)
{
if(array[right]<array[i])
{
for(int j=i;j<right;j++)
{
swap(&array[j],&array[j+1]);
location--;
}
}
}
}
}
void main()
{
int no;
printf("Enter the number of elements in the array:");
scanf("%d/n",&no);
int a[no],i;
for(i=0;i<no;i++)
{
printf("Enter the %d Element:",i+1);
scanf("%d",&a[i]);
}
quicksort(a,no,0,no-1);
for(i=0;i<no;i++)
{
printf("%d ",a[i]);
}
}