逆序建立链表
来源:互联网 发布:java colortorgb 编辑:程序博客网 时间:2024/04/30 18:13
#include<stdio.h>#include<malloc.h>
struct node
{
int data;
struct node *next;
};
struct node *creat(int n)
{
struct node *head,*tail,*p;
head=(struct node *)malloc(sizeof(struct node));
head->next=NULL;
int i;
for(i=0;i<n;i++)
{
p=(struct node *)malloc(sizeof(struct node));
scanf("%d",&p->data);
p->next=head->next;
head->next=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);
printf("\n");
return 0;
}
0 0
- 逆序建立链表
- 逆序建立链表
- 逆序建立链表
- 逆序建立链表
- 逆序建立链表
- 逆序建立链表
- 头插法建立链表--逆序输出
- 链表的建立、输出、逆序
- 链表B 逆序建立链表
- 数据结构——链表之逆序建立链表
- 山东理工ACM 2117 逆序建立链表
- 数据结构实验之链表二:逆序建立链表
- 数据结构实验之链表二:逆序建立链表
- 数据结构实验之链表二:逆序建立链表
- 数据结构实验之链表二:逆序建立链表
- SDUTOJ 2117 数据结构实验之链表二:逆序建立链表
- 数据结构实验之链表二:逆序建立链表
- 数据结构实验之链表二:逆序建立链表
- 51nod 1107 逆序对
- 【struts2】Action的实现
- 大话数据结构读书笔记 3---串
- 程序是如何执行的(三)函数调用
- gem install安装报SSL证书错误的解决办法
- 逆序建立链表
- 算法导论第六章-堆排序c++
- 线段树扫描线hdu1828Picture
- 傅里叶变换的简单理解
- 程序员之工具杂烩
- C++
- 机器学习基础(二):决策树
- MAC OS X环境下Sublime text保存失败
- HDU 1394 Minimum Inversion Number