首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
Tyu0871
2026年3月20日 22:03
遍历链表 题解:摸你
P1405
回复 0
|
赞 0
|
浏览 4
#include<bits/stdc++.h> using namespace std; int main(){ int n; while(cin>>n){ vector<int> lst; while(n--){ int temp; cin>>temp; lst.push_back(temp); } sort(lst.begin(),lst.end()); //默认升序,如果要降序可以写一个bool cmp(int a,int b)函数, ...
阿猫
2026年3月20日 11:06
遍历链表 面向对象程序设计思想解决:
P1405
回复 0
|
赞 0
|
浏览 22
#include<iostream> using namespace std; // 链表结点类 class ListNode{ public: int val; ListNode* next; ListNode(){ val=0; next=NULL; } ListNode(int x):val(x){ next=NULL; } }; // 升序链表 class DelinkList{ private: // 头结点 ListNode* head; public...
HKX9XAS
2026年3月19日 18:43
遍历链表 题解:纯C无数组,链表直接插入排序
P1405
回复 0
|
赞 1
|
浏览 7
#include<stdio.h> #include<malloc.h> typedef struct Node{ int Element; struct Node * Next; }Node; void node_insert(Node * L, Node * p){ Node * q = L; while( q->Next!=NULL && p-&g...
bro
2026年2月24日 20:36
遍历链表 题解:c++,链表
P1405
回复 0
|
赞 8
|
浏览 134
#include <bits/stdc++.h> using namespace std; struct Node{ int val; Node *next; }; int main(){ int n; int num[1004] = {0}; cin >> n; for(int i = 0; i < n ...
曾不会
2026年2月3日 09:57
遍历链表 题解:
P1405
回复 0
|
赞 0
|
浏览 123
while(1): try: n=input() num=list(map(int,input().split())) k=sorted(num) for i in k: print(i,end=' ') print() except: break
emoji
2025年3月19日 21:27
遍历链表 题解:vector和链表
P1405
回复 0
|
赞 8
|
浏览 1.4k
#include<iostream> #include<algorithm> #include<vector> using namespace std; //先用vector秒杀 /* int main(){ int n,temp; vector<int>v; while(cin>>n){ v.clear(); //防止多次输入干扰 for(int i=0;i<n;++i){ cin>>temp...
zichen9031
2025年3月7日 08:28
遍历链表 题解:
P1405
回复 0
|
赞 3
|
浏览 1.0k
函数里的struct node * pre=NULL,为什么要赋值NULL,因为我的VScode报错说使用了未初始化值的变量,我就给它赋值NULL了,hhhh #include <bits/stdc++.h> using namespace std; struct node { int sum; struct node* next; }; int n; //排序单链表,这里用的是冒泡排序 struct node* sort(struct node* head) {...
RingoCrystal
2025年2月5日 17:17
遍历链表 题解:按要求解答
P1405
回复 0
|
赞 12
|
浏览 1.2k
#include <bits/stdc++.h> using namespace std; struct node { int val; struct node* next; node(int val) : val(val), next(nullptr) {} }; node* insert(node* head, int n) { node* r = new node(n); node* p = head; // 找到插入位置 while (p->next != nullpt...
huanghu
2024年3月23日 14:27
遍历链表 题解:c++ 头插法
P1405
回复 0
|
赞 0
|
浏览 1.3k
#include <iostream> #include <vector> #include<string> #include<malloc.h> #include<algorithm> using namespace std; typedef struct LinkNode{ int data; struct LinkNode *next; }LinkNode,*LinkList; //采用头插法,因为头插法会逆置原始数组,则将arr先按从大大小排序后再传进来 LinkList cre...
wordC
2021年3月17日 10:18
1405-遍历链表,注释详细(c语言)
P1405
回复 0
|
赞 6
|
浏览 8.9k
#include <stdio.h> #include <stdlib.h> typedef struct node { int data; struct node *next; }node; //创建链表 node* createList(int num[], int length) { node *p, *head, *r; //初始化头结点 head = (node *)malloc(sizeof(node)); head->next = NULL; //r定义为尾...
1
2
题目
遍历链表
题解数量
11
发布题解
在线答疑
热门题解
1
遍历链表 题解:按要求解答
2
遍历链表 题解:c++,链表
3
遍历链表 题解:vector和链表
4
1405-遍历链表,注释详细(c语言)
5
遍历链表 题解:
6
链表构造+排序+遍历输出
7
遍历链表 题解:纯C无数组,链表直接插入排序
8
遍历链表 题解:摸你
9
遍历链表 题解:c++ 头插法
10
遍历链表 题解: