数据结构实验之链表二:逆序建立链表

Time Limit: 1000 ms Memory Limit: 65536 KiB

Problem Description

输入整数个数N,再输入N个整数,按照这些整数输入的相反顺序建立单链表,并依次遍历输出单链表的数据。

Input

第一行输入整数N;;

第二行依次输入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 <string.h>
#include <stdlib.h> typedef struct node
{
int data;
struct node *next;
}link; link *newlink()
{
link *t;
t = (link*)malloc(sizeof(link));
t->next = NULL;
return t;
} link *create(int n)
{
link *head,*q;
int i;
head = newlink();
for(i=0;i<n;i++)
{
q = newlink();
scanf("%d",&q->data);
q->next = head->next;
head->next = q;
}
return head;
} void show(link *head)
{
link *p;
p = head->next;
while(p)
{
if(p->next==NULL)
printf("%d\n",p->data);
else
printf("%d ",p->data);
p = p->next;
}
} int main()
{
int n;
link *head;
scanf("%d",&n);
head = create(n);
show(head);
return 0;
}

SDUT-2117_数据结构实验之链表二:逆序建立链表的更多相关文章

  1. SDUT OJ 数据结构实验之链表二:逆序建立链表

    数据结构实验之链表二:逆序建立链表 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descr ...

  2. ZT C语言链表操作(新增单向链表的逆序建立)

    这个不好懂,不如看 转贴:C语言链表基本操作http://www.cnblogs.com/jeanschen/p/3542668.html ZT 链表逆序http://www.cnblogs.com/ ...

  3. SDUT 2142 数据结构实验之图论二:基于邻接表的广度优先搜索遍历

    数据结构实验之图论二:基于邻接表的广度优先搜索遍历 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Descript ...

  4. SDUT OJ 数据结构实验之二叉树二:遍历二叉树

    数据结构实验之二叉树二:遍历二叉树 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descr ...

  5. SDUT OJ 数据结构实验之串二:字符串匹配

    数据结构实验之串二:字符串匹配 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descrip ...

  6. SDUT OJ 数据结构实验之排序二:交换排序

    数据结构实验之排序二:交换排序 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descrip ...

  7. SDUT 3399 数据结构实验之排序二:交换排序

    数据结构实验之排序二:交换排序 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 冒泡排序和快 ...

  8. SDUT 3374 数据结构实验之查找二:平衡二叉树

    数据结构实验之查找二:平衡二叉树 Time Limit: 400MS Memory Limit: 65536KB Submit Statistic Problem Description 根据给定的输 ...

  9. SDUT 3341 数据结构实验之二叉树二:遍历二叉树

    数据结构实验之二叉树二:遍历二叉树 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 已知二叉 ...

随机推荐

  1. Python 易错点

    1. Python查找一个变量时会按照“局部作用域”, “嵌套作用域”, “全局作用域”,“内置作用域”的顺序进行搜索. 在实际开发中,我们应该尽量减少对全局变量的使用,因为全局变量的作用域和影响过于 ...

  2. 微信小程序滚动到某个位置添加class效果。

    <scroll-view scroll-y="true" style="height:100vh;" bindscrolltoupper="up ...

  3. WPF学习笔记-用Expression Blend制作自定义按钮

    1.从Blend工具箱中添加一个Button,按住shift,将尺寸调整为125*125; 2.右键点击此按钮,选择Edit control parts(template)>Edit a cop ...

  4. Tr A HDU 1575 (矩阵快速幂)

    #include<iostream> #include<vector> #include<string> #include<cmath> #includ ...

  5. 解决Cesium1.50对gltf2.0/3dtiles数据读取的问题

    问题说明 Cesium 1.50(2018/10/01)版本打开3dtiles可能会出现加载不上导致渲染停止的错误. 错误说明为:RuntimeError: Unsupported glTF Exte ...

  6. 学习Python笔记---列表简介

    列表: 列表由一系列按特定顺序排列的元素组成.你可以创建包涵字母表中所有字母.数字0-9或所有家庭成员姓名的列表:也可以将任何东西加入列表中,其中的元素之间可以没有任何关系. 列表 在Python中, ...

  7. Linux下允许MySQL 授权远程连接

    1.mysql -u root -p   (root)用户名 2.mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'r ...

  8. 2017-09-23-ArchData

    layout: post title: ArchData category: Technical tags: [分布式,区块链,AI,大数据] ArchData 技术峰会 神经网络和函数式编程 杨博: ...

  9. Leetcode54. Spiral Matrix螺旋矩阵

    给定一个包含 m x n 个元素的矩阵(m 行, n 列),请按照顺时针螺旋顺序,返回矩阵中的所有元素. 示例 1: 输入: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ...

  10. web前端学习(三)css学习笔记部分(3)-- css常用操作

    5.  CSS常用操作 5.1  对齐 使用margin属性进行水平对齐 <!DOCTYPE html> <html lang="en"> <head ...