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 有疑问?点这里^_^ 题目描述 对于一个基于二元运算符的后缀表示式(基本操作数都是 ...
随机推荐
- PyInstaller打包成exe可执行文件
PyInstaller 安装pyinstaller 对于那些网络比较稳定,能够流畅使用pip源地址的用户,直接下面的命令就可以搞定: pip install pyinstaller 通常我们会下载源码 ...
- 从cocos2d-x-2.x到cocos2d-x-3.x: lua项目配置
cocos2dx-x3.0的正式版出来也有一段时间了,现在最新的版本是到了3.2alpha,和2.x系列相比,能够找到的相关资料除了官网上的wiki,其他的也不见得多,遇到的一些和2.x的差异和问题在 ...
- SESSION的知识
android模拟表单用到了httpclient,但是需要了解Jsessionid的相关知识 如下是从一篇博文摘抄来的 在web应用的开发中我们会经常看到这样的url:http://www.xxx.c ...
- 仿函数(二、stl中常用仿函数)
提到C++ STL,首先被人想到的是它的三大组件:Containers, Iterators, Algorithms,即容器,迭代器和算法.容器为用户提供了常用的数据结构,算法大多是独立于容器的常用的 ...
- Jmeter调度器配置
Jmeter的线程组设置里有一个调配器设置,用于设置该线程组下脚本执行的开始时间.结束时间.持续时间及启动延迟时间.当需要半夜执行性能测试时会用到这个功能. ps:设置调度器配置,需要将前面的循环次数 ...
- Springboot21 整合redis、利用redis实现消息队列
1 前提准备 1.1 创建一个springboot项目 技巧01:本博文基于springboot2.0创建 1.2 安装redis 1.2.1 linux版本 参考博文 1.2.2 windows版本 ...
- Realsense D430 python pointclound
来自:https://github.com/IntelRealSense/librealsense/issues/1231------------------------------ import p ...
- Win10 linux子系统Ubuntu下显示图形界面
转载 https://jingyan.baidu.com/article/ed2a5d1f98577809f6be17a3.html 打开终端界面,在这个窗口测试一下ls命令,无误. # 更新 sud ...
- Windows下用Nginx配置遇到的问题
Nginx是一款轻量级的web服务器/反向代理服务器,更详细的释义自己百度了.目前国内像新浪.网易等都在使用它.先说下我的服务器软件环境: 系统:Windows Server + IIS + ngin ...
- Entity Framework 6.0 Tutorials(5):Command Interception
Interception: Here, you will learn how to intercept EF when it executes database commands. EF 6 prov ...