首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
emoji
2025年3月19日 21:27
遍历链表 题解:vector和链表
P1405
回复 0
|
赞 4
|
浏览 286
#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
|
浏览 400
函数里的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
|
赞 9
|
浏览 642
#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
|
浏览 955
#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
|
赞 4
|
浏览 8.6k
#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定义为尾...
kodou
2020年7月5日 21:13
链表构造+排序+遍历输出
P1405
回复 0
|
赞 1
|
浏览 9.8k
#include<bits/stdc++.h> using namespace std; struct node{ int num; struct node *next; }; struct node * create(){ struct node *head; head = (struct node*)malloc(sizeof(node)); head->num...
题目
遍历链表
题解数量
6
发布题解
在线答疑
热门题解
1
遍历链表 题解:按要求解答
2
1405-遍历链表,注释详细(c语言)
3
遍历链表 题解:vector和链表
4
遍历链表 题解:
5
链表构造+排序+遍历输出
6
遍历链表 题解:c++ 头插法