数据结构实验之链表一:顺序建立链表
来源:互联网 发布:java序列化常用的地方 编辑:程序博客网 时间:2024/06/11 06:41
数据结构实验之链表一:顺序建立链表
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic
Problem Description
输入N个整数,按照输入的顺序建立单链表存储,并遍历所建立的单链表,输出这些数据。
Input
第一行输入整数的个数N;
第二行依次输入每个整数。
第二行依次输入每个整数。
Output
输出这组整数。
Example Input
812 56 4 6 55 15 33 62
Example Output
12 56 4 6 55 15 33 62
Hint
不得使用数组!
Author
呃呃 给某位学霸
#include <iostream>#include <stdlib.h>using namespace std;struct node{ int data; struct node * next;};struct node * creat(int n){ struct node * p, * tail, * head; head = (struct node * )malloc(sizeof(struct node)); head->next = NULL; tail = head; for(int i = 0; i < n; i++) { p = (struct node * )malloc(sizeof(struct node)); cin >> p->data; p->next = NULL; tail->next = p; tail = p; } return head;};void show(struct node * head){ struct node * p; p = head->next; while(p->next != NULL) { cout << p->data << " "; p = p->next; } cout << p->data << endl;}int main(){ struct node * head; int n; cin >> n; head = creat(n); show(head); return 0;}
0 0
- 数据结构实验之链表一:顺序建立链表
- 数据结构实验之链表一:顺序建立链表
- 数据结构实验之链表一:顺序建立链表
- 数据结构实验之链表一:顺序建立链表
- SDUTOJ 2116 数据结构实验之链表一:顺序建立链表
- 数据结构实验之链表一:顺序建立链表
- 数据结构实验之链表一:顺序建立链表
- 【2116】数据结构实验之链表一:顺序建立链表
- 数据结构实验之链表一:顺序建立链表
- 数据结构实验之链表一:顺序建立链表
- SDUTOJ 2116 数据结构实验之链表一:顺序建立链表
- 数据结构实验之链表一:顺序建立链表
- SDUT 2116 数据结构实验之链表一:顺序建立链表
- 数据结构实验之链表一:顺序建立链表
- 数据结构实验之链表一:顺序建立链表
- 数据结构实验之链表一:顺序建立链表
- 数据结构实验之链表一:顺序建立链表
- 数据结构实验之链表一:顺序建立链表
- 在一个数组中保存10个数值,然后在数组中插入一个数,数组中的数仍然有序
- python中的热更新或动态加载
- Nginx与IIS服务器搭建集群的方法
- 编写程序实现对给定的4 个整数从大到小的顺序排列
- 利用java的反射机制模拟hibernate
- 数据结构实验之链表一:顺序建立链表
- 编写程序求一元二次方程的根
- 从今开始,我要开始写博客啦
- EF6 增删改查
- 分段函数1
- 安卓实现拍照、在手机中选择图片通过webservice上传图片到服务器
- 输入一个字符,判断它是否为小写字母
- CSDN爬虫(二)——博客列表分页爬虫+数据表设计
- 第一行代码,第三次读后笔记,全书的目录摘要。