时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K = 3, then you must output 3→2→1→6→5→4; if K = 4, you must output 4→3→2→1→5→6. Input Specification: Each input file contains one test case. For each case, the first line contains the address of the first node, a positive N (<= 105) which is the total number of nodes, and a positive K (<=N) which is the length of the sublist to be reversed. The address of a node is a 5-digit nonnegative integer, and NULL is represented by -1. Then N lines follow, each describes a node in the format: Address Data Next where Address is the position of the node, Data is an integer, and Next is the position of the next node. Output Specification: For each case, output the resulting ordered linked list. Each node occupies a line, and is printed in the same format as in the input. Sample Input: 00100 6 4 00000 4 99999 00100 1 12309 68237 6 -1 33218 3 00000 99999 5 68237 12309 2 33218 Sample Output: 00000 4 33218 33218 3 12309 12309 2 00100 00100 1 99999 99999 5 68237 68237 6 -1
关注
码龄 粉丝数 原力等级 --
- 被采纳
- 被点赞
- 采纳率
用C语言实现Reversing Linked List
收起
- 写回答
- 好问题 0 提建议
- 关注问题
微信扫一扫点击复制链接分享
- 邀请回答
- 编辑 收藏 删除 结题
- 收藏 举报
1条回答 默认 最新
- 关注
码龄 粉丝数 原力等级 --
- 被采纳
- 被点赞
- 采纳率
devmiao 2015-04-17 18:27关注本回答被题主选为最佳回答 , 对您是否有帮助呢? 本回答被专家选为最佳回答 , 对您是否有帮助呢? 本回答被题主和专家选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏举报
微信扫一扫点击复制链接分享
评论按下Enter换行,Ctrl+Enter发表内容
报告相同问题?
提交
- 2020-12-01 08:14Love 6的博客 (c语言)浙大数据结构Mooc作者答案集 下面是关于这道题的图片 关于这道题的闲谈 关于这道题第一次我看到的时候,一点点思路都没有,甚至连题意都没会出来,我还以为是中间的数字进行翻转,旁边的地址都是不依次连接...
- 2020-03-23 14:46执念斩长河的博客 本实验取材于浙江大学《数据结构》. ...一个好的c语言包含了三样东西 输入 处理 输出 很显然这道题的难点在于处理,下面给出 #include<stdio.h> #include<stdlib.h> #define MAXLEN 1...
- 2024-07-11 12:23L_glonar的博客 总结,我的个人问题,一味的认为链表的线性表高级,便一直用,但是忘了要符合实际,顺序表的查找是O(1), 线性表是O(N),而且我的跟裹脚布一样,太长了<^v^> Given a constant K and a singly linked list L, you...
- 2020-07-06 22:58有三只土豆的博客 1. 利用数组存储节点 2. 利用初始地址及 next 地址,为列表排序,并以 -1 为终点,记录真实节点数目 3. 根据 k 值,反转...* 最初想用链表的 next 地址值尾插反转链表,突然想到,此地址值并不是真的内存地址(卒~)
- 2018-03-26 23:34Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K=3, then you must output 3→2→1→6→5→...
- 2022-03-17 19:32DinosaurKing的博客 02-线性结构3 Reversing Linked List (25 分)
- 2022-05-07 22:00cai_est的博客 } 排序函数(时间复杂度高,多使用map) LNode sort(LNode head) { LNode L = new Node; L->next_address = head->address; L->next = NULL; LNode L_last = L; LNode newnode; LNode temp = head->next; while (L_...
- 2021-08-05 14:18十一点睡~的博客 1074 Reversing Linked List 题目大意 读入一条链表,遍历该链表,将链表上的结点按照每m个结点为一组进行反转,按顺序输出反转后的链表的每一个结点 核心思路 从begin开始遍历链表上的每一个结点,将链表上每一个...
- 2020-10-11 21:35qy流火的博客 Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K=3, then you must output 3→2→1→6→5→...
- 2019-10-21 10:56hide on codes的博客 02-线性结构3 Reversing Linked List (25 分) mooc数据结构网课上的作业题,大概说下题目要求: 先输入三个参数 (首地址address 结点个数N 需逆转序列长度k) 然后输入N个格式为(当前地址 数据值 下个地址 )的...
- 2020-12-30 02:31我们都曾拥有最美的时光的博客 Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K = 3, then you must output 3→2→1
- 2021-08-01 17:45爱吃梦龙雪糕的博客 反转链表问题,属于容易忘记的一类题型 坑点如下 1,链表的生成模板 结构体 struct Node{ int data; int address; int next; int order; }node[maxn]; 读入数据 for(int i=0;i<n;i++){ ...
- 2019-03-20 15:10Ocean_VV的博客 自己用C写的反转子链表函数。。。先上个图 题目应该都理解了,就不解释了。。说一下,“有多余节点不在链表上”, 后来一直卡在这个点上。。。。 这个样例是指,给定的N个节点中,可能有很多是不在单链表中...
- 2016-11-11 15:49Van0512的博客 #include #include #include #include #include using namespace std; struct Node{ char addr[6]; int data; char next[6]; }; int main(void) { string firstAddr; int n, k;... cin
- 2020-04-19 21:28卡卡kkscn的博客 Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K=3, then you must output 3→2→1→6→5→...
- 2018-03-24 14:44闲不下来的王小C的博客 Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K=3, then you must output 3→2→1→6→5→...
- 没有解决我的问题, 去提问