Service

What is wrong with my sorting function?

What is wrong with my sorting function?

What is wrong with my sorting function? head is a global variable 

void medianscore(){

struct student *sort=head,*temp,*sort1=head;
struct student *k=head;
struct student *la=head;
while(sort!=NULL){
        while(la!=NULL){
        printf("While loopn");
        if(sort->grade>la->grade){
               temp=sort->next;
               la->next=sort->next->next;
               sort=temp;
}
      else{
               sort=sort->next;
               la=la->next;
}
}
}


struct student *j=head;
while(j!=NULL){
printf("First name: %5s %2d, Last name: %5s %2d, Score: %5.2f %2d, Zipcode: %5d %2dn",j->firstname,count,j->lastname,count,j->grade,count,j->zip,count);
j=j->next;
}
}

Liam Smith 07-Nov-2017

Answer (UnSolved)

question Get solution