文章

3

粉丝

490

获赞

1

访问

31.6k

头像
单链表解法
P1015 贵州大学机试题
发布于2020年6月5日 15:47
阅读数 9.9k

虽然各种函数多,但结构清晰明了

#include <stdio.h>
#include <stdlib.h>

typedef struct Node{
    int Element;
    struct Node *Next;
}Node, *LinkList;

bool InitList(LinkList &L){//带头结点 
    L = (Node *)malloc(sizeof(Node));
    if(L==NULL)    return false;
    L->Next = NULL;
    return true;
}

bool Insert(LinkList &L, int e){
    if(L==NULL)    return false;
    Node *p = (Node *)malloc(sizeof(Node));
    p->Element = e;
    p->Next = L->Next;
    L->Next = p;
    return true;
}

void sort(LinkList &L, int len){
    for(int i=0; i<len; i++){
        Node *p = L->Next;
        while(p->Next != NULL){
       &n...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发