linux虚拟机读写win host机的文件

有两个数组a[4]={3,5,8,11};和 b[7]={2,6,8,9,11,15,20};分别把它们放入两个动态链表中,然后按由小到大的顺序把它们放到第三个空链表中。

 

#include  " stdafx.h "
#include  
< stdio.h >  
typedef 
struct  L {
    
int num; 
    
struct L *next;
}
L,  * LinkList;
/**  此函数的功能是建立链表,返回值为头指针。*/  
void  CreatList (LinkList  & m,  int   * pa,  int  n) 
{     
    m 
= (LinkList)malloc(sizeof(L));
    m
->next = NULL; 
    
for(int i = 0; i < n; i++
    

        LinkList s 
= (LinkList)malloc(sizeof(L));
        s
->num = *(pa + i); 
        s
->next = m->next; 
        m
->next = s; 
    }
  
}
 
void  Insert(LinkList  & x, LinkList  & y, LinkList  & z) 

    z 
= (LinkList)malloc(sizeof(L));
    z
->next = NULL;
    
while(y->next)
    
{//这部分不具有通用性,完全是看到你的数组已经排好了序,才这样偷工减料了。
     
//你自己可以改进,使其具有通用性。
        LinkList p = (LinkList)malloc(sizeof(L));
        p
->num = y->next->num;
        p
->next = z->next;
        z
->next = p;
        y 
= y->next;
    }

    
while(x->next)
    
{
        LinkList ppre 
= z;
        LinkList q 
= (LinkList)malloc(sizeof(L));
        q
->num = x->next->num;
        
while(q->num >= ppre->next->num)
            ppre 
= ppre->next;
        q
->next = ppre->next;
        ppre
->next = q;
        x 
= x->next;
    }

}
 
void  main() 

    
int a[4= {35811}
    
int b[7= {2689111520}
    LinkList LA 
= NULL, LB = NULL, LC = NULL; 
    CreatList (LA, a, 
4); 
    CreatList (LB, b, 
7);
    Insert(LA, LB, LC); 
    
for(LinkList i = LC->next; i != NULL; i = i->next) 
        printf(
"%d ", i->num);  
}
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值