sort the data and printf sorted datas;
using Insertion sort;
#include<stdio.h>
struct people{
int number;
struct people *next;
};
struct people *inrear(){
struct people *p,*top,*rear,*p1,*p2;
int n;
scanf("%d",&n);
top=rear=NULL;
while(n!=0){
p=(struct people *)malloc(sizeof(struct people));
p->number=n;
p->next=NULL;
if(rear==NULL){
rear=p;
top=p;
}
else{
p1=top;
p2=NULL;
while(p1!=NULL&&(p->number)>(p1->number)){
p2=p1;
p1=p1->next;
}
if(p1==NULL)
rear->next=p;
rear=p;
if(p2==NULL){
p->next=top;
top=p;
}
if(p1!=NULL&&p2!=NULL){
p->next=p1;
p2->next=p;
}
}
scanf("%d",&n);
}
return top;
}
void putup(struct people *top){
struct people *p;
while(top!=NULL){
printf("%d ",top->number);
p=top;
top=top->next;
free(p);
}
}
void main(){
struct people *fp;
fp=inrear();
putup(fp);
return 0;
}
**
creat; modify or process;search;Insert;
**