链表---理论
发布日期:2021-06-29 05:35:35 浏览次数:3 分类:技术文章

本文共 614 字,大约阅读时间需要 2 分钟。

1学习网址

1:

2 链表的创建

#include 
#include
#include
struct node {
int num;struct node *next;};struct node *create(int n){
int i; struct node *head=NULL; struct node *mid,*tail; for(i=n;i>0;i--) {
mid=(struct node*)malloc(sizeof(struct node)); if(mid==NULL) {
perror("mid"); exit(-1); } scanf("%d",&(mid->num)); if(head==NULL) head=mid; else tail->next=mid; tail=mid; } tail->next=NULL; return head;}int main(int argc,char** argv){
int n; struct node *p; scanf("%d",&n); p=create(n); while(p) {
printf("%d ",p->num); p=p->next; } printf("\n"); return 0;}

转载地址:https://blog.csdn.net/zhi_Alanwu/article/details/104854560 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:结构体对齐理论
下一篇:NRF52832笔记(11)ble绑定和配对

发表评论

最新留言

感谢大佬
[***.8.128.20]2024年04月10日 09时06分48秒