| |
|
|
开发:
C++知识库
Java知识库
JavaScript
Python
PHP知识库
人工智能
区块链
大数据
移动开发
嵌入式
开发工具
数据结构与算法
开发测试
游戏开发
网络协议
系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程 数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁 |
| -> 数据结构与算法 -> 1052 Linked List Sorting分数 25 -> 正文阅读 |
|
|
[数据结构与算法]1052 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? Input Specification:Each input file contains one test case. For each case, the first line contains a positive?N?(<105) and an address of the head node, where?N?is the total number of nodes in memory and the address of a node is a 5-digit positive integer. NULL is represented by??1. Then?N?lines follow, each describes a node in the format:
where? Output Specification:For each test case, the output format is the same as that of the input, where?N?is the total number of nodes in the list and all the nodes must be sorted order. Sample Input:
Sample Output:
代码长度限制 16 KB 时间限制 400 ms 内存限制 64 MB 思路:很典型的一道PAT链表题了,具体的结构实现就是用一个结构体里面存储key和next,然后他的结构体数组下标代表的就是目前这个数的地址,要注意的就是是否有多余的链表,从head开始一直next,直到最后一个,这样就把有效的链表都统计了下来,因为题目明确说明了key值是独一无二的(distinct),所以我们就用map来存储对应的key值,然后对应到地址上面,map的自动排序功能就可以让我们顺利输出啦! 代码:
? |
|
|
|
|
| 上一篇文章 下一篇文章 查看所有文章 |
|
|
开发:
C++知识库
Java知识库
JavaScript
Python
PHP知识库
人工智能
区块链
大数据
移动开发
嵌入式
开发工具
数据结构与算法
开发测试
游戏开发
网络协议
系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程 数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁 |
| 360图书馆 购物 三丰科技 阅读网 日历 万年历 2025年11日历 | -2025/11/22 11:35:33- |
|
| 网站联系: qq:121756557 email:121756557@qq.com IT数码 |