当前位置: 首页 > news >正文

[STL]list使用介绍

[STL]list使用

注:本文测试环境是visual studio2019。

文章目录

  • [STL]list使用
    • 1. list介绍
    • 2. 构造函数
    • 3. 迭代器相关函数
      • begin函数和end函数
      • rbegin函数和rend函数
    • 4. 容量相关函数
      • empty函数
      • size函数
    • 5. 数据修改函数
      • push_back函数和pop_back函数
      • push_front函数和pop_front函数
      • insert函数和erase函数
      • swap函数
      • resize函数
      • clear函数
    • 6. 数据操作函数
      • sort函数
      • reverse函数
      • merge函数
      • unique函数
      • remove函数
      • splice函数

1. list介绍

  1. list是可以在常量时间内在任意位置进行插入和删除的序列式容器,并且该容器可以前后双向迭代。
  2. list的底层是双向链表结构,双向链表中每个元素存储在互不相关的独立节点中,在节点中通过指针指向其前一个元素和后一个元素。
  3. list与forward_list非常相似:最主要的不同在于forward_list是单链表,只能朝前迭代,已让其更简单高效。
  4. 与其他的序列式容器相比(array,vector,deque),list通常在任意位置进行插入、移除元素的执行效率更好。
  5. 与其他序列式容器相比,list和forward_list最大的缺陷是不支持任意位置的随机访问,比如:要访问list 的第6个元素,必须从已知的位置(比如头部或者尾部)迭代到该位置。

2. 构造函数

image-20230618212401437

(1)构造函数

默认构造函数。

list<int> l; //创建一个空list

(2)构造函数

创建一个有n个结点,结点数据为val的list。

list<int> l(10, 66); 

(3)构造函数

使用迭代器构造列表。

vector<int> v(10, 6);
list<int> l(v.begin(), v.end()); //创建一个存储int类型的链表,使用v初始化数据

(4)构造函数

拷贝构造函数

list<int> l1(10,6);
list<int> l2(l1); //使用l2拷贝构造l1

3. 迭代器相关函数

begin函数和end函数

begin函数:

返回指向list第一个结点的正向迭代器。

end函数:

返回指向list结尾的正向迭代器。

#include <iostream>
#include <list>
#include <vector>
using namespace std;
int main()
{vector<int> v;v.push_back(1); //在list中尾插数据1v.push_back(2); //在list中尾插数据2v.push_back(3);	//在list中尾插数据3v.push_back(4);	//在list中尾插数据4list<int> l(v.begin(), v.end());list<int>::iterator it = l.begin();while (it != l.end()){cout << *it << " ";it++;}cout << endl; //输出为 1 2 3 4return 0;
}

rbegin函数和rend函数

rbegin函数:

返回指向list最后一个含有数据的结点的反向迭代器。

rend函数:

指向list反向结尾的反向迭代器。

#include <iostream>
#include <list>
#include <vector>
using namespace std;
int main()
{vector<int> v;v.push_back(1); //在list中尾插数据1v.push_back(2); //在list中尾插数据2v.push_back(3);	//在list中尾插数据3v.push_back(4);	//在list中尾插数据4list<int> l(v.begin(), v.end());list<int>::reverse_iterator it = l.rbegin();while (it != l.rend()){cout << *it << " ";it++;}cout << endl; //输出为 4 3 2 1return 0;
}

4. 容量相关函数

empty函数

判断list是否为空.

#include <iostream>
#include <list>
#include <vector>
using namespace std;
int main()
{list<int> l1;list<int> l2(5, 6);cout << l1.empty() << endl;//输出为1cout << l2.empty() << endl;//输出为0return 0;
}

size函数

获取list存储的结点个数。

#include <iostream>
#include <list>
#include <vector>
using namespace std;
int main()
{vector<int> v;v.push_back(1); //在list中尾插数据1v.push_back(2); //在list中尾插数据2v.push_back(3);	//在list中尾插数据3v.push_back(4);	//在list中尾插数据4list<int> l(v.begin(), v.end());cout << l.size() << endl;  //输出为4return 0;
}

5. 数据修改函数

push_back函数和pop_back函数

push_back函数:

在list结尾插入结点。

#include <iostream>
#include <list>
using namespace std;
int main()
{list<int> l;l.push_back(1);l.push_back(2);l.push_back(3);cout << l.size() << endl; //输出为3return 0;
}

pop_back函数:

在list结尾删除结点。

#include <iostream>
#include <list>
using namespace std;
int main()
{list<int> l;l.push_back(1);l.push_back(2);l.push_back(3);cout << l.size() << endl; //输出为3l.pop_back();l.pop_back();cout << l.size() << endl; //输出为1l.pop_back();//l.pop_back(); -- 报错 -- 没有结点可删return 0;
}

push_front函数和pop_front函数

push_front函数:

在list中头插结点。

#include <iostream>
#include <list>
using namespace std;
int main()
{list<int> l;l.push_front(1);l.push_front(2);l.push_front(3);l.push_front(4);list<int>::iterator it = l.begin();while (it != l.end()){cout << *it << " ";++it;}cout << endl; // 输出为 4 3 2 1return 0;
}

pop_front函数:

在list中头删结点。

#include <iostream>
#include <list>
using namespace std;
int main()
{list<int> l;l.push_front(1);l.push_front(2);l.push_front(3);l.push_front(4);list<int>::iterator it = l.begin();while (it != l.end()){cout << *it << " ";++it;}cout << endl;l.pop_front();l.pop_front();it = l.begin();while (it != l.end()){cout << *it << " ";++it;}cout << endl; // 输出为 2 1return 0;
}

insert函数和erase函数

和vector容器类似,list容器也没有提供find函数,而insert函数和erase函数是需要配合迭代器使用的,因此需要使用算法库的find函数。

image-20230619211015257

find函数查找成功会返回指向数据的迭代器,失败会返回传入的last迭代器,注意find函数的查找范围是从first迭代器至last迭代器前,不包括last迭代器。

insert函数

功能1: 在某一位置插入结点。

#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
int main()
{list<int> l;l.push_back(1);l.push_back(2);l.push_back(3);l.push_back(4);list<int>::iterator pos = find(l.begin(), l.end(), 2);l.insert(pos, 66);list<int>::iterator it = l.begin();while (it != l.end()){cout << *it << " ";++it;}cout << endl; //输出为1 66 2 3 4return 0;
}

功能2: 在某一位置插入n个存储相同数据的结点。

#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
int main()
{list<int> l;l.push_back(1);l.push_back(2);l.push_back(3);l.push_back(4);list<int>::iterator pos = find(l.begin(), l.end(), 2);l.insert(pos, 3, 66);list<int>::iterator it = l.begin();while (it != l.end()){cout << *it << " ";++it;}cout << endl; //输出为1 66 66 66 2 3 4return 0;
}

功能3: 传入其他list容器或者其他类型容器的迭代器,将传入的迭代器区间内的数据插入。

#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
int main()
{list<int> l1(3, 66);list<int> l2;l2.push_back(1);l2.push_back(2);l2.push_back(3);list<int>::iterator pos = find(l2.begin(), l2.end(), 2);l2.insert(pos, l1.begin(), l1.end());list<int>::iterator it = l2.begin();while (it != l2.end()){cout << *it << " ";++it;}cout << endl;  //输出为1 66 66 66 2 3return 0;
}

erase函数

功能1: 删除迭代器指向的结点。

#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
int main()
{list<int> l;l.push_back(1);l.push_back(2);l.push_back(3);list<int>::iterator pos = find(l.begin(), l.end(), 2);l.erase(pos);list<int>::iterator it = l.begin();while (it != l.end()){cout << *it << " ";++it;}cout << endl; // 输出为 1 3return 0;
}

功能2: 将迭代器范围的结点都删除。

#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
int main()
{list<int> l;l.push_back(1);l.push_back(2);l.push_back(3);l.push_back(4);l.push_back(5);list<int>::iterator start = find(l.begin(), l.end(), 2);list<int>::iterator finish = find(l.begin(), l.end(), 5);l.erase(start, finish);list<int>::iterator it = l.begin();while (it != l.end()){cout << *it << " ";++it;}cout << endl; // 输出为 1 5return 0;
}

swap函数

将两个list数据交换,通过交换list指向的头结点实现。

#include <iostream>
#include <list>
using namespace std;
int main()
{list<int> l1(3, 66);list<int> l2;l2.push_back(1);l2.push_back(2);l2.push_back(3);l1.swap(l2);list<int>::iterator it1 = l1.begin();while (it1 != l1.end()){cout << *it1 << " ";  //输出为 1 2 3++it1;}cout << endl;list<int>::iterator it2 = l2.begin();while (it2 != l2.end()){cout << *it2 << " "; //输出为 66 66 66++it2;}cout << endl;return 0;
}

resize函数

image-20230619215305106

  1. 如果n < size, 会将结点删除至list只有n个结点,由于list结点的释放成本是不高的,因此不同于vector只是将末尾指向修改,list会实际上的在调用resize函数时的删除结点。
  2. 如果n > size,就将插入结点使得list有n个结点
#include <iostream>
#include <list>
using namespace std;
int main()
{list<int> l;l.push_back(1);l.push_back(2);l.push_back(3);l.push_back(4);l.push_back(5);cout << l.size() << endl; //输出为5l.resize(3); // n < sizecout << l.size() << endl; //输出为3l.resize(6); // n > sizecout << l.size() << endl; //输出为6return 0;
}

clear函数

释放所有结点,使得list为空链表。

#include <iostream>
#include <list>
using namespace std;
int main()
{list<int> l(66, 6);cout << l.size() << endl; // 输出为66l.clear();cout << l.size() << endl; // 输出为0return 0;
}

6. 数据操作函数

sort函数

对list中的数据进行排序。

#include <iostream>
#include <list>
using namespace std;int main()
{list<int> l1;l1.push_back(2);l1.push_back(1);l1.push_back(4);l1.push_back(7);l1.push_back(5);l1.push_back(9);l1.push_back(8);l1.sort();list<int>::iterator it = l1.begin();it = l1.begin();while (it != l1.end()){cout << *it << ' ';  //输出为: 1 2 4 5 7 8 9it++;}return 0;
}

注: 由于list是链表实现的,迭代器是双向迭代器,因此不能调用algorithm库内的sort函数,因此需要单独设计sort函数,但是list的sort函数由于结构原因导致性能不高。

reverse函数

将list内的结点逆置。

#include <iostream>
#include <list>
using namespace std;
int main()
{list<int> l;l.push_back(1);l.push_back(2);l.push_back(3);l.push_back(4);list<int>::iterator it = l.begin();while (it != l.end()){cout << *it << ' ';  //输出为: 1 2 3 4it++;}l.reverse(); //将list逆置it = l.begin();while (it != l.end()){cout << *it << ' '; //输出为: 4 3 2 1it++;}cout << endl;return 0;
}

merge函数

如果两个list有序并且排序方式相同,可以将一个list的结点连接到另一个list上并保持有序,排序方式和连接前相同。

#include <iostream>
#include <list>
using namespace std;
int main()
{list<int> l1;l1.push_back(1);l1.push_back(2);l1.push_back(3);l1.push_back(4);list<int> l2;l2.push_back(6);l2.push_back(7);l2.push_back(8);l2.push_back(9);l2.merge(l1); //将l1的结点连接到l2,连接后l1为空list<int>::iterator it = l2.begin();while (it != l2.end()){cout << *it << ' ';it++;}cout << endl;return 0;
}

unique函数

只能给数据有序的list进行数据去重操作,如果数据无序去重操作会出现问题。

#include <iostream>
#include <list>
using namespace std;
int main()
{list<int> l;l.push_back(1);l.push_back(2);l.push_back(2);l.push_back(2);l.push_back(3);l.push_back(3);l.push_back(3);l.push_back(4);l.unique();	//对list内的数据去重list<int>::iterator it = l.begin();while (it != l.end()){cout << *it << ' ';	// 输出为: 1 2 3 4it++;}cout << endl;return 0;
}

remove函数

查找对应的数据并进行删除操作,数据存在就删除,不存在不会进行任何操作。

#include <iostream>
#include <list>
using namespace std;
int main()
{list<int> l;l.push_back(1);l.push_back(2);l.push_back(3);l.push_back(4);l.remove(3); //删除数据为3的结点list<int>::iterator it = l.begin();while (it != l.end()){cout << *it << ' '; //输出为: 1 2 4it++;}cout << endl;return 0;
}

splice函数

将以一个list的指定部分的结点转移给其他list。

#include <iostream>
#include <list>
using namespace std;int main()
{list<int> l1;l1.push_back(1);l1.push_back(2);l1.push_back(3);l1.push_back(4);list<int> l2;l2.push_back(5);l2.push_back(6);l2.push_back(9);l2.push_back(8);list<int>::iterator it = l1.begin();l1.splice(it, l2); //将l2的所有结点转移到l1的begin位置it = l1.begin();while (it != l1.end()){cout << *it << ' '; //输出为:5 6 9 8 1 2 3 4it++;}return 0;
}

相关文章:

[STL]list使用介绍

[STL]list使用 注&#xff1a;本文测试环境是visual studio2019。 文章目录 [STL]list使用1. list介绍2. 构造函数3. 迭代器相关函数begin函数和end函数rbegin函数和rend函数 4. 容量相关函数empty函数size函数 5. 数据修改函数push_back函数和pop_back函数push_front函数和pop…...

k8s服务发现之第五弹--使用 Service 连接到应用

Kubernetes 的网络模型 通过前面教程的学习&#xff0c;我们已经可以将容器化的应用程序在 Kubernetes 中运行起来&#xff0c;并且发布到 Kubernetes 内/外的网络上。 通常&#xff0c;Docker 使用一种 host-private 的联网方式&#xff0c;在此情况下&#xff0c;只有两个容…...

SAP ABAP 自定义表数据导入

一:效果展示&#xff1a; 读取 Excel 数据到 SAP 数据库表。 二&#xff1a;源码&#xff1a; *&---------------------------------------------------------------------* *& Report ZTEST_DRW02 *&----------------------------------------------------------…...

目标检测识别——大恒(DaHeng)相机操作与控制编程

文章目录 引言正文相关开发库的介绍编程准备配置引用头文件GalaxyIncludes.h配置lib文件 具体编程过程初始化和反初始化枚举设备开关设备 属性控制属性控制器种类 图像采集控制和图像处理采单帧回调采集 总结 引言 在做老师的横向项目时&#xff0c;需要用大恒相机&#xff0c…...

国标GB28181视频监控平台EasyGBS视频无法播放,抓包返回ICMP是什么原因?

国标GB28181视频平台EasyGBS是基于国标GB/T28181协议的行业内安防视频流媒体能力平台&#xff0c;可实现的视频功能包括&#xff1a;实时监控直播、录像、检索与回看、语音对讲、云存储、告警、平台级联等功能。国标GB28181视频监控平台部署简单、可拓展性强&#xff0c;支持将…...

如何正确使用npm常用命令

npm常用命令&#xff1a; 官方文档&#xff1a;CLI Commands | npm Docs 1. npm -v&#xff1a;查看 npm 版本 2. npm init&#xff1a;初始化后会出现一个 Package.json 配置文件&#xff0c;可以在后面加上 -y&#xff0c;快速跳到问答界面 3. npm install&#xff1a;会…...

无人机影像配准并发布(共线方程)

无人机影像 DEM 计算四个角点坐标&#xff08;刚性变换&#xff09; 像空间坐标&#xff08;x,y,-f&#xff09; 像空间坐标畸变纠正 deltax,deltay 已知(x,y)&#xff0c;求解(X,Y, Z)或者(Lat,Lon) 这里的Z是DEM上获取的坐标和Zs为相机坐标的高程&#xff0c;如果均为已…...

openGauss学习笔记-23 openGauss 简单数据管理-时间/日期函数和操作符

文章目录 openGauss学习笔记-23 openGauss 简单数据管理-时间/日期函数和操作符23.1 时间日期操作符23.2 时间/日期函数23.3 TIMESTAMPDIFF23.4 EXTRACT23.5 date_part openGauss学习笔记-23 openGauss 简单数据管理-时间/日期函数和操作符 23.1 时间日期操作符 用户在使用时…...

C++OpenCV(7):图像形态学基础操作

&#x1f506; 文章首发于我的个人博客&#xff1a;欢迎大佬们来逛逛 &#x1f506; OpenCV项目地址及源代码&#xff1a;点击这里 文章目录 膨胀与腐蚀形态学基础 膨胀与腐蚀 膨胀与腐蚀是数学形态学在图像处理中最基础的操作。 膨胀操作是取每个位置领域内最大值&#xff0…...

Appium+python自动化(二十二)- 控件坐标获取(超详解)

简介 有些小伙伴或者是童鞋可能会好奇会问上一篇中的那个monkey脚本里的坐标点是如何获取的&#xff0c;不是自己随便蒙的猜的&#xff0c;或者是自己用目光或者是尺子量出来的吧&#xff0c;答案当然是&#xff1a;NO。获取控件坐标点的方式这里宏哥给小伙伴们分享和讲解三种方…...

Tensorflow benchmark 实操指南

环境搭建篇见环境搭建-CentOS7下Nvidia Docker容器基于TensorFlow1.15测试GPU_东方狱兔的博客-CSDN博客 1. 下载Benchmarks源码 从 TensorFlow 的 Github 仓库上下载 TensorFlow Benchmarks&#xff0c;可以通过以下命令来下载 https://github.com/tensorflow/benchmarks 我…...

【linux】调试工具介绍

文章目录 前言一、kdb二、ftrace三、gdb 前言 在Linux内核调试过程中&#xff0c;可以使用各种工具和技术来诊断和解决问题。以下是一些常用的Linux内核调试方法&#xff1a; printk&#xff1a;printk是Linux内核中的打印函数&#xff0c;可以在代码中插入打印语句来输出调试…...

2.获取DOM元素

获取DOM元素就是利用JS选择页面中的标签元素 2.1 根据CSS选择器来获取DOM元素(重点) 2.1.1选择匹配的第一个元素 语法: document.querySelector( css选择器 )参数: 包含一个或多个有效的CSS选择器 字符串 返回值: CSS选择器匹配的第一个元素&#xff0c;一个HTMLElement对象…...

flask中redirect、url_for、endpoint介绍

flask中redirect、url_for、endpoint介绍 redirect 在 Flask 中&#xff0c;redirect() 是一个非常有用的函数&#xff0c;可以使服务器发送一个HTTP响应&#xff0c;指示客户端&#xff08;通常是浏览器&#xff09;自动导航到新的 URL。基本上&#xff0c;它是用来重定向用…...

《MySQL》第十二篇 数据类型

目录 一. 整数类型二. 浮点类型三. 日期和时间类型四. 字符串类型五. 枚举值类型六. 二进制类型七. 小结 MySQL 支持多种数据类型&#xff0c;学习好数据类型&#xff0c;才能更好的学习 MySQL 表的设计&#xff0c;让表的设计更加合理。 一. 整数类型 类型大小SIGNED(有符号)…...

Python与OpenCV环境中,借助SIFT、单应性、KNN以及Ransac技术进行实现的图像拼接算法详细解析及应用

一、引言 在当今数字化时代,图像处理技术的重要性不言而喻。它在无人驾驶、计算机视觉、人脸识别等领域发挥着关键作用。作为图像处理的一个重要部分,图像拼接算法是实现广阔视野图像的重要手段。今天我们将会讲解在Python和OpenCV环境下,如何使用SIFT、单应性、KNN以及Ran…...

苍穹外卖Day01项目日志

1.软件开发流程和人员分工是怎样的&#xff1f; 软件开发流程 一个软件是怎么被开发出来的&#xff1f; 需求分析 先得知道软件定位人群、用户群体、有什么功能、要实现什么效果等。 需要得到需求规格说明书、产品原型。 需求规格说明书 其中前后端工程师要关注的就是产品原…...

Netty学习(二)

文章目录 二. Netty 入门1. 概述1.1 Netty 是什么&#xff1f;1.2 Netty 的作者1.3 Netty 的地位1.4 Netty 的优势 2. Hello World2.1 目标加入依赖 2.2 服务器端2.3 客户端2.4 流程梳理课堂示例服务端客户端 分析提示&#xff08;重要&#xff09; 3. 组件3.1 EventLoop事件循…...

ReactRouterv5在BrowserRouter和HashRouter模式下对location.state的支持

结论&#xff1a;HashRouter不支持location.state 文档&#xff1a;ReactRouter v5 从文档可看到history.push()方法支持2个参数&#xff1a;path, [state] state即是location.state&#xff0c;常用于隐式地传递状态参数 但文档未提的是&#xff0c;仅适用于BrowserRouter&am…...

Aerotech系列文章(3)运动设置命令Motion Setup Commands

1.运动设置命令Motion Setup Commands 斜坡类型&#xff1a; 直线&#xff0c;S曲线&#xff0c;与正弦曲线 Enumerator: RAMPTYPE_Linear Linear-based ramp type. RAMPTYPE_Scurve S-curve-based ramp type. RAMPTYPE_Sine Sine-based ramp type. 函数原型&a…...

云原生核心技术 (7/12): K8s 核心概念白话解读(上):Pod 和 Deployment 究竟是什么?

大家好&#xff0c;欢迎来到《云原生核心技术》系列的第七篇&#xff01; 在上一篇&#xff0c;我们成功地使用 Minikube 或 kind 在自己的电脑上搭建起了一个迷你但功能完备的 Kubernetes 集群。现在&#xff0c;我们就像一个拥有了一块崭新数字土地的农场主&#xff0c;是时…...

线程同步:确保多线程程序的安全与高效!

全文目录&#xff1a; 开篇语前序前言第一部分&#xff1a;线程同步的概念与问题1.1 线程同步的概念1.2 线程同步的问题1.3 线程同步的解决方案 第二部分&#xff1a;synchronized关键字的使用2.1 使用 synchronized修饰方法2.2 使用 synchronized修饰代码块 第三部分&#xff…...

Leetcode 3577. Count the Number of Computer Unlocking Permutations

Leetcode 3577. Count the Number of Computer Unlocking Permutations 1. 解题思路2. 代码实现 题目链接&#xff1a;3577. Count the Number of Computer Unlocking Permutations 1. 解题思路 这一题其实就是一个脑筋急转弯&#xff0c;要想要能够将所有的电脑解锁&#x…...

el-switch文字内置

el-switch文字内置 效果 vue <div style"color:#ffffff;font-size:14px;float:left;margin-bottom:5px;margin-right:5px;">自动加载</div> <el-switch v-model"value" active-color"#3E99FB" inactive-color"#DCDFE6"…...

Java-41 深入浅出 Spring - 声明式事务的支持 事务配置 XML模式 XML+注解模式

点一下关注吧&#xff01;&#xff01;&#xff01;非常感谢&#xff01;&#xff01;持续更新&#xff01;&#xff01;&#xff01; &#x1f680; AI篇持续更新中&#xff01;&#xff08;长期更新&#xff09; 目前2025年06月05日更新到&#xff1a; AI炼丹日志-28 - Aud…...

PL0语法,分析器实现!

简介 PL/0 是一种简单的编程语言,通常用于教学编译原理。它的语法结构清晰,功能包括常量定义、变量声明、过程(子程序)定义以及基本的控制结构(如条件语句和循环语句)。 PL/0 语法规范 PL/0 是一种教学用的小型编程语言,由 Niklaus Wirth 设计,用于展示编译原理的核…...

微软PowerBI考试 PL300-在 Power BI 中清理、转换和加载数据

微软PowerBI考试 PL300-在 Power BI 中清理、转换和加载数据 Power Query 具有大量专门帮助您清理和准备数据以供分析的功能。 您将了解如何简化复杂模型、更改数据类型、重命名对象和透视数据。 您还将了解如何分析列&#xff0c;以便知晓哪些列包含有价值的数据&#xff0c;…...

2025季度云服务器排行榜

在全球云服务器市场&#xff0c;各厂商的排名和地位并非一成不变&#xff0c;而是由其独特的优势、战略布局和市场适应性共同决定的。以下是根据2025年市场趋势&#xff0c;对主要云服务器厂商在排行榜中占据重要位置的原因和优势进行深度分析&#xff1a; 一、全球“三巨头”…...

网站指纹识别

网站指纹识别 网站的最基本组成&#xff1a;服务器&#xff08;操作系统&#xff09;、中间件&#xff08;web容器&#xff09;、脚本语言、数据厍 为什么要了解这些&#xff1f;举个例子&#xff1a;发现了一个文件读取漏洞&#xff0c;我们需要读/etc/passwd&#xff0c;如…...

VM虚拟机网络配置(ubuntu24桥接模式):配置静态IP

编辑-虚拟网络编辑器-更改设置 选择桥接模式&#xff0c;然后找到相应的网卡&#xff08;可以查看自己本机的网络连接&#xff09; windows连接的网络点击查看属性 编辑虚拟机设置更改网络配置&#xff0c;选择刚才配置的桥接模式 静态ip设置&#xff1a; 我用的ubuntu24桌…...