当前位置:网站首页>尾插法构造链表
尾插法构造链表
2022-07-22 10:40:00 【LH2HA3】
#include<stdio.h>
#include<stdlib.h>
typedef struct LNode{
int data; //数据域
struct LNode *next; //指针域
} LNode,*LinkList;
LinkList L;
void ListInerst(LinkList &L,int i){//尾插法
L=(LNode *)malloc(sizeof(LNode));
L->next=NULL;
//头指针
LNode *s,*r=L;//声明两个游动指针
while(i!=0){
s=(LNode *)malloc(sizeof(LNode));
printf("请输入数据:");
scanf("%d",&s->data);
r->next=s;
r=s;
--i;
}
r->next=NULL;//最后必须保证最后一个结点指针与为空
}
void display(LinkList L){ //遍历链表
LNode *p;
p=L->next;
while(p!=NULL){
printf("%d",p->data);
p=p->next;
}
}
void Text(){
ListInerst(L, 5);
display(L);
}
int main(){
Text();
return 0;
}
边栏推荐
猜你喜欢
Canny edge detection
Aminer paper recommendation
二分查找(递归函数)
Lire attentivement le document DETR et analyser la structure du modèle
Her power series III holds the current, adheres to love, and is tied to the scientific research road of food image recognition
Automatic generation of common centroid capacitance array with arbitrary capacitance ratio
进程fork
YOLO v1、v2、v3
栈实现(C语言)
基于非线性最坏情况分析的电荷缩放 DAC 中电容器的新棋盘放置和尺寸调整方法
随机推荐
AMBert
模拟QQ登陆界面
Latex compiles and reports errors in vscode `recipe terminated with error Retry building the project.
模拟电路中晶体管阵列的性能感知公共质心布局和布线 ALIGN
PAT-2021年冬季考试(满分)
7-4 helping the couriers (30 points)
1064 Complete Binary Search Tree (30 分)
八大排序(直接插入排序)
redission扣库存demo
1080 graduate admission (30 points)
1068 Find More Coins (30 分)
Aminer paper recommendation
c语言bitField
配置属于自己的Vim-编辑器之神
[FPGA]: IP Core - - DDR3
1080 Graduate Admission (30 分)
DEFORMABLE DETR 论文精度,并解析网络模型结构
Hill sort (minimum incremental sort)
redission分布式锁种类
Opportunity of code 2020 -- boarding seat problem