数据结构实验之链表一:顺序建立链表(SDUT 2116)
Problem Description
输入N个整数,按照输入的顺序建立单链表存储,并遍历所建立的单链表,输出这些数据。
Input
第一行输入整数的个数N;
第二行依次输入每个整数。Output
输出这组整数。
Sample Input
8
12 56 4 6 55 15 33 62Sample Output
12 56 4 6 55 15 33 62
Hint
不得使用数组!
#include <bits/stdc++.h>
using namespace std;
struct node
{
int data;
struct node *next;
};
int main()
{
int n;
struct node *head, *tail, *p;
head = new node;
head -> next = NULL;
tail = head;
scanf("%d",&n);
for(int i = 0; i < n; i ++)
{
p = new node;
p -> next = NULL;
scanf("%d", &p -> data);
tail -> next = p;
tail = p;
}
for(p = head -> next ; p != NULL; p = p -> next)
{
if(p == head -> next)
printf("%d",p->data);
else
printf(" %d",p->data);
}
printf("\n");
return 0;
}
数据结构实验之链表一:顺序建立链表(SDUT 2116)的更多相关文章
- SDUT OJ 数据结构实验之链表一:顺序建立链表
数据结构实验之链表一:顺序建立链表 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descr ...
- SDUT-2116_数据结构实验之链表一:顺序建立链表
数据结构实验之链表一:顺序建立链表 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 输入N个整数,按照输入的顺序建立单链 ...
- 链表-简单练习题1-数据结构实验之链表一:顺序建立链表 SDUT2117
Problem Description 输入N个整数,按照输入的顺序建立单链表存储,并遍历所建立的单链表,输出这些数据. Input 第一行输入整数的个数N:第二行依次输入每个整数. Output 输 ...
- 数据结构实验2:C++实现单链表类
太简单了,直接贴题目然后上代码. 题目: 实验2 2.1 实验目的 熟练掌握线性表的链式存储结构. 熟练掌握单链表的有关算法设计. 根据具体问题的需要,设计出合理的表示数据的链式存储结构,并设计相关算 ...
- 数据结构实验之数组三:快速转置(SDUT 3347)
Problem Description 转置运算是一种最简单的矩阵运算,对于一个m*n的矩阵M( 1 = < m < = 10000,1 = < n < = 10000 ),它 ...
- 数据结构实验之数组二:稀疏矩阵(SDUT 3348)
Problem Description 对于一个n*n的稀疏矩阵M(1 <= n <= 1000),采用三元组顺序表存储表示,查找从键盘输入的某个非零数据是否在稀疏矩阵中,如果存在则输出O ...
- 数据结构实验之排序六:希尔排序 (SDUT 3403)
其实,感觉好像增量不同的冒泡,希尔排序概念以后补上. #include <bits/stdc++.h> using namespace std; int a[10005]; int b[1 ...
- 数据结构实验之排序三:bucket sort (SDUT 3400)
桶排序: #include <stdio.h> #include <string.h> int a[5555555]; int main() { int n,m; scanf( ...
- 数据结构实验之查找一:二叉排序树 (SDUT 3373)
二叉排序树(Binary Sort Tree),又称二叉查找树(Binary Search Tree),也称二叉搜索树. #include <stdio.h> #include <s ...
随机推荐
- easyui datagrid 合并相同行
$.extend($.fn.datagrid.methods, { autoMergeCells: function (jq, fields) { return jq.each(function () ...
- Elastic Search快速上手(4):细节补充
模糊搜索 可以进行模糊搜索: GET job/type1/_search { "query":{ "fuzzy":{ "title":{ & ...
- vue中的键盘事件
@keydown(键盘按下时触发),@keypress(键盘按住时触发),@keyup(键盘弹起) 获取按键的键码 e.keyCode @keyup.13 按回车键 @keyup.enter ...
- 【leetcode】296.Best Meeting Point
原题 A group of two or more people wants to meet and minimize the total travel distance. You are given ...
- 【异常】 Could not find Linker 'g++' in system path.
1 详细异常 FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':az-ex ...
- 6.Tray Monitor服务(监控服务)
1. Tray Monitor服务(监控服务) 该服务需要运行在gui环境下,用于查看baclua client.存储等状态.下面以windows下安装为例. 1.1. Tray Monito ...
- windows BAT脚本2个服务器间传递文件
1. 脚本功能: 实现2个服务器间文件的传递,例如从A服务器往B服务器上传文件 2. 实现步骤: 2.1 服务器连结,找到指定路径,读取所需要上传的文件,将文件名称复制到一个文件下 (此处考虑可能需要 ...
- 工作中常用的Git操作
粘贴自:微信公众号:程序员共成长 分支操作: git branch 创建分支 git branch -b 创建并切换到新建的分支上 git checkout 切换分支 git branch 查看分支列 ...
- 面试题——SSM面试题
树木丛生红火火 树木丛生红火火 微信公众号:Java全栈开发大联盟 原文地址:https://note.youdao.com/ynoteshare1/index.html?id=3f81baea7 ...
- java——从.net再学习java
到底从java中学到了什么? 1,java是由sun公司发明的,sun希望制定一些标准,具体的实现交给具体的厂商来自己实现: 2,java是开源的,第三方做了很多自己的一些组件实现,比如: 很多时候, ...