How would you write qsort?
Answer / hardik
#include<stdio.h>
#include<conio.h>
void sort(int,int);
int *arr;
void main()
{
clrscr();
int n,ub,lb=0,i;
printf("ENTER NO OF VALUES U WANT TO ENTER : ");
scanf("%d",&ub);
for(i=0;i<ub;i++)
{
printf("\ENter value : ");
scanf("%d",&arr[i]);
}
sort(lb,ub);
for(i=0;i<ub;i++)
printf("%d\t",arr[i]);
getch();
}
void sort(int lb,int ub)
{
int flag=1,temp,key,i,j;
i=lb; j=ub;
key=arr[i];
if(lb<ub)
{
while(flag)
{
i++;
while(key>arr[i])
i++;
while(key<arr[j])
j--;
if(i<j)
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
else
flag=0;
}
temp=arr[lb];
arr[lb]=arr[j];
arr[j]=temp;
sort(lb,j-1);
sort(j+1,ub);
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
How old is c programming language?
While compiling a c program,graphics header files are not including in my program..eg: <graphics.h>,what may be the problem...is there any environment settings exists.
Can an array be an Ivalue?
Can anyone tell what is stack overflow? what precaution we should take?
write a C program, given number is double without using addt ion and multiplication operator?ex:n=6,ans=12,pls send me ans to goviseenu@gmail.com
Program to find the value of e raised to power x using while loop
How arrays can be passed to a user defined function
Why do we use & in c?
can anyone proide me reading material on svit00ef27@yahoo.com please thanx in advance
c program to manipulate x=1!+2!+3!+...+n! using recursion
Is c a great language, or what?
char ch="{'H','I',0};printf("%s",ch);what is output