Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   WTF is wrng with this code????? (http://www.go4expert.com/forums/wtf-wrng-code-t27357/)

chetan3191 13Dec2011 22:16

WTF is wrng with this code?????
 
Code:

#include<stdio.h>
void quick(int[],int);

main(){
int a[]={11,2,5,4,7,3};
int len=sizeof(a)/sizeof(a[0]);
quick(a,len);

int i=0;
while(i<len){
printf("%d,",a[i]);
i++;
}
}





void quick(int a[],int len){

int pivot=a[0];
int loc=0;
int i=0,j=len-1;

while(i!=j){

while(j>=0 && i!=j ){
if(a[j]<pivot){
    printf("asdasdad");
a[loc]=a[j];
loc=j;
break;
}
j--;
}

while(a[i]<len && i!=j){
if(a[i]>pivot){   
a[loc]=a[i];
loc=i;
break;
}
i++;
}

}

a[i]=pivot;
}




copy this code in ur compiler and try out..... it does not work for the given array of numbers......it a quick sort implementation for the first recursive step.....recursion is pending...i will do it later....but this problem has to be sorted out first.

shabbir 14Dec2011 09:06

Re: WTF is wrng with this code?????
 
Duplicate of http://www.go4expert.com/showthread.php?t=27359

Thread closed. Please don't create the same thread more than once.


All times are GMT +5.5. The time now is 06:08.