SDUT OJ 数据结构实验之链表三:链表的逆置
数据结构实验之链表三:链表的逆置
Problem Description
Input
Output
Sample Input
12 56 4 6 55 15 33 62 -1
Sample Output
62 33 15 55 6 4 56 12
Hint
相当于从头开始拆下来再逆序建立一遍;
#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *next;
};
int main()
{
struct node *head, *tail, *p, *q;
head = (struct node *)malloc(sizeof(struct node));
head->next = NULL;
tail = head;
int n;
while(scanf("%d",&n)&&n!=-1)
{
p = (struct node *)malloc(sizeof(struct node));
p->next = NULL;
p->data = n;
tail->next = p;
tail = p;
}
p = head->next;
head->next = NULL;
q = p->next;
while(p){
p->next = head->next;
head->next = p;
p = q;
if(q) q = q->next;
}
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 数据结构实验之串三:KMP应用
数据结构实验之串三:KMP应用 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descrip ...
- SDUT OJ 数据结构实验之排序三:bucket sort
数据结构实验之排序三:bucket sort Time Limit: 250 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem D ...
- SDUT 3311 数据结构实验之串三:KMP应用
数据结构实验之串三:KMP应用 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 有n个小朋友 ...
- SDUT 3347 数据结构实验之数组三:快速转置
数据结构实验之数组三:快速转置 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 转置运算是一 ...
- SDUT 3400 数据结构实验之排序三:bucket sort
数据结构实验之排序三:bucket sort Time Limit: 150MS Memory Limit: 65536KB Submit Statistic Problem Description ...
- SDUT 3375 数据结构实验之查找三:树的种类统计
数据结构实验之查找三:树的种类统计 Time Limit: 400MS Memory Limit: 65536KB Submit Statistic Problem Description 随着卫星成 ...
- SDUT 3342 数据结构实验之二叉树三:统计叶子数
数据结构实验之二叉树三:统计叶子数 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 已知二叉 ...
- SDUT 2133 数据结构实验之栈三:后缀式求值
数据结构实验之栈三:后缀式求值 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 对于一个基于二元运算符的后缀表示式(基本操作数都是 ...
随机推荐
- component to string 自定义窗体
component to string string to component StringToComponent ComponentToString ObjectTextToBinary Objec ...
- 解决The JSP specification requires that an attribute name is preceded by whitespace问题
笔者今天调试界面出现下边这个问题: The JSP specification requires that an attribute name is preceded by whitespace 经查 ...
- (转)CSS布局-负边距-margin
css中的负边距(negative margin)是布局中的一个常用技巧,只要运用得合理常常会有意想不到的效果.很多特殊的css布局方法都依赖于负边距,所以掌握它的用法对于前端的同学来说,那是必须的. ...
- idata的各个类型
idata是51系列单片机能识别的存储器类型之一,固定指前面0x00-0xff的256个字节的片内RAM,其中前128字节和data的128字节完全相同,只是因为访问的方式不同.idata是用类似C中 ...
- dom方式解析xml文件的步骤
使用java类即可
- JS中使用正则表达式
- Linux 安装(重装)mysql
1 新建存放mysql相关文件的文件夹 mkdir -p /export/servers/mysql //存放mysql相关的几个rpm文件 2 查看原有mysql 并卸载 rpm -qa | gre ...
- hdu3530 Subsequence
题意:There is a sequence of integers. Your task is to find the longest subsequence that satisfies the ...
- 把List<string>转为DataTable
//把List<string>转为DataTable List<string> myList = new List<string>(); DataTable dt2 ...
- C#获取当前站点的根地址
/// <summary> /// 得到当前网站的根地址 /// </summary> /// <returns></returns> protecte ...