Professional Documents
Culture Documents
h>
#include <stdlib.h>
#include<string.h>
if(head==NULL)
return;
printBack(head->next);
if(head->dob.date<10&&head->dob.month<10){
printf(" %s 0%d0%d%d %d %.2f \n",head->name,head->dob.date,head-
>dob.month,head->dob.year,head->height,head->weight);
}
else if(head->dob.date<10){
printf(" %s 0%d%d%d %d %.2f \n",head->name,head->dob.date,head-
>dob.month,head->dob.year,head->height,head->weight);
}else if(head->dob.month<10){
printf(" %s %d0%d%d %d %.2f \n",head->name,head->dob.date,head-
>dob.month,head->dob.year,head->height,head->weight);
}else
if(head==NULL)
return;
if(head->dob.month/10 ==0){
char dp[10] = "0";
char* d = (char*)malloc(sizeof(char)*4);
char ch = '0'+head->dob.month;
/*itoa(head->dob.date,d,10);*/
d[0]=ch;
d[1]='\0';
strcat(dp,d);
printf(" %s %d%s%d %d %.2f \n",head->name,head->dob.date,dp,head-
>dob.year,head->height,head->weight);
printBack(head->next);
return;
}
print(head->next);
temp->name = s1->name;
temp->dob= s1->dob;
temp->weight= s1->weight;
temp->height= s1->height;
s1->name = s2->name;
s1->dob= s2->dob;
s1->weight= s2->weight;
s1->height= s2->height;
s2->name = temp->name;
s2->dob= temp->dob;
s2->weight= temp->weight;
s2->height= temp->height;
int len =0 ;
while(cur1 != NULL){
len++;
cur1=cur1->next;
}
return len;
}
temp->name = s1->name;
temp->dob= s1->dob;
temp->weight= s1->weight;
temp->height= s1->height;
return temp;
}
temp->name = s1->name;
temp->dob= s1->dob;
temp->weight= s1->weight;
temp->height= s1->height;
temp->next = NULL;
return temp;
}
/*to get the details of a student at a required index in the linked list*/
student* get( student* head,int index){
student* cur = (student*)malloc(sizeof(student));
cur = head;
if (index >= length(head))
return NULL;
while(index>0){
cur = cur->next;
index--;
}
return cur;
student* st = get(head,s);
student* temp = copy(st);
t = t->next;
cur = cur->next;
s++;
}
return temp;
}
if(start>=end){
return;
}
else if( end-start == 1){
if( difference(head->dob,head->next->dob)==1 )
swap(head,head->next);
return;
}
/*partitin*/
student* left = partL(head,start,mid);
student* right = partL(head,mid+1,end);
/*recur mergeSort*/
mergeSort(left,0,length(left)-1);
mergeSort(right,0,length(right)-1);
copyData(cur,Lptr);
Lptr= Lptr->next;
cur = cur->next;
}
else if( difference(Lptr->dob,Rptr->dob)==1 ){
copyData(cur,Rptr);
Rptr= Rptr->next;
cur = cur->next;
}
}
while(Lptr!=NULL){
copyData(cur,Lptr);
Lptr= Lptr->next;
cur = cur->next;
}
while(Rptr!=NULL){
copyData(cur,Rptr);
Rptr= Rptr->next;
cur = cur->next;
}
while(n>0){
student* newNode ;
if(cur==NULL){
newNode = (student*)malloc(sizeof(student));
cur = newNode;
}
if(prev!=NULL){
prev->next = newNode;
}
fflush(stdin);
scanf("%s",name);
cur->name = name;
scanf("%d",&date);
(cur->dob).year = date%10000;
date=date/10000;
(cur->dob).month = date%100;
date = date/100;
(cur->dob).date = date;
scanf("%d %f",&(cur->height),&(cur->weight));
cur->next = NULL;
prev = cur;
cur = cur->next;
n--;
}
mergeSort(head,0,length(head)-1);
printBack(head);
return 0;
}