SDUT OJ 数据结构实验之链表二:逆序建立链表
数据结构实验之链表二:逆序建立链表
Problem Description
Input
第二行依次输入N个整数,逆序建立单链表。
Output
Sample Input
10
11 3 5 27 9 12 43 16 84 22
Sample Output
22 84 16 43 12 9 27 5 3 11
Hint
先理解吧,顺序建立链表和逆序建立链表都各自敲十遍以上再去做其他题;
#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *next;
};
int main()
{
struct node *p, *head;
head = (struct node *)malloc(sizeof(struct node));
head->next = NULL;
int i, n;
scanf("%d",&n);
for(i=0; i<n; i++){
p = (struct node *)malloc(sizeof(struct node));
scanf("%d",&p->data);
p->next = head->next;
head->next = p;
}
p=head->next;
while(p->next){
printf("%d ",p->data);
p = p->next;
} printf("%d\n",p->data);
return 0;
}
SDUT OJ 数据结构实验之链表二:逆序建立链表的更多相关文章
- SDUT OJ 数据结构实验之二叉树二:遍历二叉树
数据结构实验之二叉树二:遍历二叉树 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descr ...
- SDUT OJ 数据结构实验之串二:字符串匹配
数据结构实验之串二:字符串匹配 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descrip ...
- SDUT OJ 数据结构实验之排序二:交换排序
数据结构实验之排序二:交换排序 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descrip ...
- SDUT-2117_数据结构实验之链表二:逆序建立链表
数据结构实验之链表二:逆序建立链表 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 输入整数个数N,再输入N个整数,按照 ...
- ZT C语言链表操作(新增单向链表的逆序建立)
这个不好懂,不如看 转贴:C语言链表基本操作http://www.cnblogs.com/jeanschen/p/3542668.html ZT 链表逆序http://www.cnblogs.com/ ...
- SDUT OJ 数据结构实验之链表三:链表的逆置
数据结构实验之链表三:链表的逆置 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descri ...
- SDUT OJ 数据结构实验之链表一:顺序建立链表
数据结构实验之链表一:顺序建立链表 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descr ...
- SDUT 2142 数据结构实验之图论二:基于邻接表的广度优先搜索遍历
数据结构实验之图论二:基于邻接表的广度优先搜索遍历 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Descript ...
- SDUT 3399 数据结构实验之排序二:交换排序
数据结构实验之排序二:交换排序 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 冒泡排序和快 ...
随机推荐
- CSS a 标签样式
CSS a 标签样式 a:LINK { color: red; } a:VISITED { color: yellow; } a:HOVER { color: green; } a:ACTIVE { ...
- RAD 10 新控件 TSearchBox TSplitView
Seattle新控件 1.TSearchBox Events OnInvokeSearch published Occurs when the search indicator button is c ...
- 在linux中获取错误返回信息 &…
#include // void perror(const char *msg); #include // char *strerror(int errnum); #include //errno e ...
- Java多线程-新特征-原子量
所谓的原子量即操作变量的操作是“原子的”,该操作不可再分,因此是线程安全的. 为何要使用原子变量呢,原因是多个线程对单个变量操作也会引起一些问题.在Java5之前,可以通过volatile.synch ...
- 2-1 gradle安装
因为Gradle是基于JVM的,所以一定要确保本机已经安装了JDK,我们可以通过java -version来验证一下是否已经安装了JDK. bin目录里面是两个可执行文件,一个是Windows下面的 ...
- Elasticsearch聚合限制内存使用
限制内存使用 通常为了让聚合(或者任何需要访问字段值的请求)能够快点,访问fielddata一定会快点, 这就是为什么加载到内存的原因.但是加载太多的数据到内存会导致垃圾回收(gc)缓慢, 因为JVM ...
- [bzoj3223]文艺平衡树(splay区间反转模板)
解题关键:splay模板题. #include<cstdio> #include<cstring> #include<algorithm> #include< ...
- 【SQL Server数据迁移】把csv文件中的数据导入SQL Server的方法
[sql] view plaincopy --1.修改系统参数 --修改高级参数 sp_configure 'show advanced options',1 go --允许即席分布式查询 sp_co ...
- Virtual Machine Definition File 2.2
Virtual Machine Definition File 2.2 http://archives.opennebula.org/documentation:archives:rel2.2:tem ...
- 27-拓扑排序-poj1094
http://poj.org/problem?id=1094 Sorting It All Out Time Limit: 1000MS Memory Limit: 10000K Total Su ...