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 冒泡排序和快 ...
随机推荐
- Python基础学习三 字符串
字符串方法 slit = ['a', 'b', 'c', 'd', 'f', 'g'] s2='hhhhhhhhhh' tu = (1,2,3,4,5) d={'name':'nnn','age':1 ...
- axis调用webservice客户端开发
第一步:wsdl2Java.bat文件编写 Axis_Lib表示依赖的jar包路径 Output_Path表示生成的class路径 Package包名 还需要手动更改 -p %Package%表示we ...
- 【原】Coursera—Andrew Ng机器学习—课程笔记 Lecture 2_Linear regression with one variable 单变量线性回归
Lecture2 Linear regression with one variable 单变量线性回归 2.1 模型表示 Model Representation 2.1.1 线性回归 Li ...
- 转载--解决ora-00119和ora-00132这个问题
前提:服务全部打开,监听也配置好了! win7 64位 Oracle 11g 简单的sql命令: 先登录到sqlplus: sqlplus /nolog; 登录数据库: conn system/ ...
- 字节流之文件输出流FileOutputStream
文件拷贝:
- 【原创】12. MYSQL++之Template Query
1. 什么是Template Query 在我们实际的编程过程中,我们很容易碰到printf这类需要在运行时来决定到底打印出什么的函数,例如 printf(“hello %s”, sth); 在这个例 ...
- laravel中的数据库操作(增删改查)方法一
导入命名空间和DBnamespace App\Http\Controllers; use Illuminate\Support\Facades\DB; public function index(){ ...
- CF407B Long Path
好玩的题. 首先我们(看一下题解之后)发现当你第一次走到了一个点的时候,那么它之前的所有点一定都访问过了偶数次. 假设我们第一次走到了一个点$i$,那么$i - 1$一定访问了偶数次,那么第一次走$i ...
- Python 之 文件处理
文件操作: 文件路径:d:\文件名.txt 编码方式:utf-8.gbk 操作方式:只读.只写.追加.读写.写读... 只读:r 或 rb #相对路径 f=open("文件名& ...
- 第十三课 Actionlib(2)
上节课讲到了客户端,这节课讲解一下服务器 1.创建服务器源文件touch fibonacciserver.cpp 2.编写源文件 3.修改CMakeLists.txt 4.编译之catkin_make ...