链表
小·幸·运
你的所有努力最后都会回赠予你。
展开
-
PAT乙级B1025 反转链表 (25)
给定一个常数K以及一个单链表L,请编写程序将L中每K个结点反转。例如:给定L为1→2→3→4→5→6,K为3,则输出应该为3→2→1→6→5→4;如果K为4,则输出应该为4→3→2→1→5→6,即最后不到K个元素不反转。 输入格式: 每个输入包含1个测试用例。每个测试用例第1行给出第1个结点的地址、结点总个数正整数N(<= 10^5^)、以及正整数K(<=N),即要求反转的子链结点...原创 2018-07-23 21:22:33 · 240 阅读 · 0 评论 -
PAT甲级A1074 Reversing Linked List (25)
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 ...原创 2018-07-23 22:18:42 · 304 阅读 · 0 评论 -
PAT甲级A1032 Sharing (25)
To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example,...原创 2018-08-20 22:17:57 · 188 阅读 · 0 评论 -
PAT甲级A1052 Linked List Sorting (25 分)
A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now give...原创 2019-01-19 20:14:21 · 128 阅读 · 1 评论 -
PAT甲级A1097 Deduplication on a Linked List (25 分)
Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or a...原创 2019-02-24 15:07:26 · 247 阅读 · 1 评论 -
PAT甲级A1133 Splitting A Linked List (25 分)
Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all those grea...原创 2019-03-10 16:54:13 · 191 阅读 · 0 评论 -
PAT乙级B1075 链表元素分类 (25 分)
给定一个单链表,请编写程序将链表元素进行分类排列,使得所有负值元素都排在非负值元素的前面,而 [0, K] 区间内的元素都排在大于 K 的元素前面。但每一类内部元素的顺序是不能改变的。例如:给定链表为 18→7→-4→0→5→-6→10→11→-2,K 为 10,则输出应该为 -4→-6→-2→7→0→5→10→18→11。 输入格式: 每个输入包含一个测试用例。每个测试用例第 1 行给出:第...原创 2019-03-07 15:04:52 · 319 阅读 · 0 评论