#include
#include
#includetypedef struct list{
int deta;
struct list *next;
}node,*link;link delete_node(link pointer,link tmp){
if(tmp==NULL) return pointer->next;
else{
if(tmp->next->next==NULL) tmp->next=NULL;
else tmp->next=tmp->next->next;
return pointer;
}
}void selection_minode(link pointer,int num){
link tmp,btmp;
int i,min,cnt=num;
if(num==0)printf("NULL");
else if(num==1){
min=pointer->deta;
printf("%d",min);
}
else{
for(i=1;ideta;
btmp=NULL;
while(tmp->next){
if(min>tmp->next->deta){
min=tmp->next->deta;
btmp=tmp;
}
tmp=tmp->next;
}
printf("%d ",min);
pointer=delete_node(pointer,btmp);
}
min=pointer->deta;
printf("%d",min);
}
}link create_list(){
link tmp1,tmp2,pointer;
int i;
pointer=(link)malloc(sizeof(node));
scanf("%d",&i);
tmp1=pointer;
if(i==-1){
tmp1=NULL;
}
else {
tmp1->deta=i;
tmp1->next=NULL;
scanf("%d",&i);
}
while(i!=-1){
tmp2=(link)malloc(sizeof(node));
tmp2->next=NULL;
tmp2->deta=i;
tmp1->next=tmp2;
tmp1=tmp1->next;
scanf("%d",&i);
}
return pointer;
}link concatenate(link pointer1,link pointer2){
link tmp;
tmp=pointer1;
while(tmp->next) tmp=tmp->next;
tmp->next=pointer2;
return pointer1;
}int count(link ptr){
int i=0;
while(ptr->deta){
i++;
ptr=ptr->next;
}
return i;
}int main(){
link ptr1,ptr2;
int num;
ptr1=create_list();
ptr2=create_list();
concatenate(ptr1,ptr2);
num=count(ptr1);
selection_minode(ptr1,num);
return 0;
} |