顺序建立链表
来源:互联网 发布:网络聊天用语段子 编辑:程序博客网 时间:2024/04/28 15:08
#include<stdio.h>#include<malloc.h>
struct node
{
int data;
struct node *next;
};
struct node *creat(int n)
{
int i;
struct node *head,*tail,*p;
head=(struct node *)malloc(sizeof(struct node));
head->next=NULL;
tail=head;
for(i=1;i<=n;i++)
{
p=(struct node *)malloc(sizeof(struct node));
scanf("%d",&p->data);
p->next=NULL;
tail->next=p;
tail=p;
}
return head;
}
void print(struct node *head)
{
struct node *p;
p=head->next;
while(p!=NULL)
{
if(p==NULL)
printf("%d",p->data);
else printf("%d ",p->data);
p=p->next;
}
}
int main()
{
int n;
struct node *head;
scanf("%d",&n);
head=creat(n);
print(head);
return 0;
}
0 0
- 顺序建立链表
- 顺序建立链表
- 顺序建立链表
- 顺序建立链表
- 顺序建立链表
- 顺序建立链表
- 顺序建立链表
- 顺序建立链表
- 顺序建立链表
- 顺序建立链表
- 顺序建立链表(2116)
- 尾插法建立链表--顺序输出
- sdut 2116 顺序建立链表
- 链表A 顺序建立链表
- 建立顺序表
- 顺序表的建立
- 顺序表的建立(顺序存储)
- 线性表的顺序建立
- 微服务与SOA架构
- LVM逻辑卷管理
- Spring Tool Suite使用自带maven速度慢---修改settings.xml更新mirror方法
- JAVA字符数组 char[] 到字符串 String
- ceph的一些浅见——关于日志(1)
- 顺序建立链表
- leetcode---Sum Root to Leaf Numbers---树的深度遍历
- 求多个数的最小公倍数
- Java 内存管理机制与内存泄露
- Xcode8去除控制台多余打印(转)
- 2016ICPC北京站网络预选赛F hihoCoder1388 Periodic Signal,FFT|NTT+CRT
- Android之ViewDragHelper的使用
- Error:Authentication scheme ‘all’(Authentication) is not supported by protocol ‘file’
- bzoj 4326: NOIP2015 运输计划 树链剖分+二分+差分数组