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 有疑问?点这里^_^ 题目描述 对于一个基于二元运算符的后缀表示式(基本操作数都是 ...
随机推荐
- A Look at the Razor View Engine in ASP.NET MVC
The biggest architectural difference that exists between ASP.NET MVC and ASP.NET Web Forms is the ne ...
- 执行CUnit测试出错
est/test_fifo.test: error while loading shared libraries: libcunit.so.1: cannot open shared object f ...
- Win10 linux子系统Ubuntu下显示图形界面
转载 https://jingyan.baidu.com/article/ed2a5d1f98577809f6be17a3.html 打开终端界面,在这个窗口测试一下ls命令,无误. # 更新 sud ...
- 10.Execution failed with exit status: 3
错误信息: insert overwrite table t_mobile_mid_use_p_tmp4_rcf select '201411' as month_id, a.prov_id, a.c ...
- 35.MID() 函数
MID() 函数 MID() 函数 MID 函数用于从文本字段中提取字符. SQL MID() 语法 SELECT MID(column_name,start[,length]) FROM table ...
- activex打包
http://www.cnblogs.com/weiwin/p/4493835.html activeX 打包 原文 http://www.docin.com/p-409284488.html C ...
- c# 获取非托管指针长度
public List<string> GetPDFValues() { List<string> strs = new List<string>(); unsaf ...
- hrabs的数据库session的修改
using System;using System.Data;using System.Collections;using System.Collections.Generic;using Syste ...
- 实践作业3:接到任务及思考DAY1
今天,老师又布置了新的学习任务,关于白盒测试.感觉黑盒测试,我们用的比较多,白盒测试就相对陌生了.上课的时候老师虽然也进行了一定的点拨,外加我们学习了SPOC视频,但是并没有看到什么具体的项目,所以实 ...
- iOS play video
iOS: How to use MPMoviePlayerController up vote6down votefavorite 3 I've created a blank project (iO ...