文章

11

粉丝

34

获赞

0

访问

2.3k

头像
单链表 题解:顺便回忆一下头插法
P1015 贵州大学机试题
发布于2024年3月22日 15:16
阅读数 264

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <stdlib.h>
typedef struct Node {
    int Element; // 节点中的元素为整数类型
    struct Node* Next; // 指向下一个节点
}Node,*LinkList;
void Insert(LinkList& L,int e) {
    LinkList p = (Node*)malloc(sizeof(Node));
    p->Element = e;
    p->Next = L->Next;
    L->Next = p;
}
void Print(LinkList& L) {
    LinkList p = (Node*)malloc(sizeof(Node));
    p = L;
    while (p->Next != NULL) {
        p = p->Next;
        cout << p->Element << " ";
    }
}
void Reverse(LinkList& L) {
    //头插法
    LinkLi...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发