Flutter_学习记录_基本组件的使用记录

1.TextWidge的常用属性

1.1TextAlign: 文本对齐属性

常用的样式有:

  • TextAlign.center 居中
  • TextAlign.left 左对齐
  • TextAlign.right 有对齐

使用案例:

body: Center(child: Text('开启 TextWidget 的旅程吧,珠珠, 开启 TextWidget 的旅程吧,珠珠开启 TextWidget 的旅程吧,珠珠开启 TextWidget 的旅程吧,珠珠',textAlign: TextAlign.center),)

1.2 maxLines: 文本显示的最大行数

使用案例:

body: Center(child: Text('开启 TextWidget 的旅程吧,珠珠, 开启 TextWidget 的旅程吧,珠珠开启 TextWidget 的旅程吧,珠珠开启 TextWidget 的旅程吧,珠珠',textAlign: TextAlign.center,maxLines: 2)

1.3 overFlow: 控制文本的溢出效果

常用的样式有:

  • TextOverflow.clip 直接截断
  • TextOverflow.ellipsis 被截断后,末尾处用… 来表示
  • TextOverflow.fade 最后一行有个阴影

使用案例:

body: Center(child: Text('开启 TextWidget 的旅程吧,珠珠, 开启 TextWidget 的旅程吧,珠珠开启 TextWidget 的旅程吧,珠珠开启 TextWidget 的旅程吧,珠珠',textAlign: TextAlign.center,maxLines: 2,overflow: TextOverflow.ellipsis),)

1.4 style 样式

style 给文本添加样式,需要用到组件TextStyle, 查看TextStyle 的定义如下:

 const TextStyle({this.inherit = true,this.color,this.backgroundColor,this.fontSize,this.fontWeight,this.fontStyle,this.letterSpacing,this.wordSpacing,this.textBaseline,this.height,this.leadingDistribution,this.locale,this.foreground,this.background,this.shadows,this.fontFeatures,this.fontVariations,this.decoration,this.decorationColor,this.decorationStyle,this.decorationThickness,this.debugLabel,String? fontFamily,List<String>? fontFamilyFallback,String? package,this.overflow,}

使用案例:

body: Center(child: Text('开启 TextWidget 的旅程吧,珠珠',textAlign: TextAlign.center,style: TextStyle(fontSize: 25.0,color: Color.fromARGB(255, 255, 150, 150),decoration: TextDecoration.underline,decorationStyle: TextDecorationStyle.solid),),)

2. Container 容器组件

2.1 Alignment 属性的使用

常用样式:

/// The top left corner.
static const Alignment topLeft = Alignment(-1.0, -1.0);
/// The center point along the top edge.
static const Alignment topCenter = Alignment(0.0, -1.0);
/// The top right corner.
static const Alignment topRight = Alignment(1.0, -1.0);
/// The center point along the left edge.
static const Alignment centerLeft = Alignment(-1.0, 0.0);
/// The center point, both horizontally and vertically.
static const Alignment center = Alignment(0.0, 0.0);
/// The center point along the right edge.
static const Alignment centerRight = Alignment(1.0, 0.0);
/// The bottom left corner.
static const Alignment bottomLeft = Alignment(-1.0, 1.0);
/// The center point along the bottom edge.
static const Alignment bottomCenter = Alignment(0.0, 1.0);
/// The bottom right corner.
static const Alignment bottomRight = Alignment(1.0, 1.0);

2.2 设置宽高和颜色

高: height
宽:width
背景色:color

2.3 Padding 内边距属性的使用

两种设置方式:

  • EdgeInsets.all(xx) 上下左右的内边距统一设置
  • EdgeInsets.fromLTRB(left, top, right, bottom) 上下左右单独设置

2.4 margin外边距属性的使用

两种设置方式:

  • EdgeInsets.all(xx) 上下左右的内边距统一设置
  • EdgeInsets.fromLTRB(left, top, right, bottom) 上下左右单独设置

2.5 decoration 属性制作彩色背景

需要使用组件BoxDecoration 来设置

decoration: BoxDecoration(gradient: const LinearGradient(colors: [Colors.lightBlue,Colors.greenAccent,Colors.purple]))

2.5 使用案例

body: Center(child: Container(alignment: Alignment.topLeft,width: 500.0,height: 300.0,// color: Colors.lightBlue,padding: const EdgeInsets.fromLTRB(50, 20, 10, 30), // 上下左右边距都一样的margin: const EdgeInsets.all(10.0),decoration: BoxDecoration(gradient: const LinearGradient(colors: [Colors.lightBlue,Colors.greenAccent,Colors.purple])),child: Text('开启 TextWidget 的旅程吧,珠珠',textAlign: TextAlign.left,style: TextStyle(fontSize: 45.0,color: Color.fromARGB(255, 255, 150, 150),decoration: TextDecoration.underline,decorationStyle: TextDecorationStyle.solid),),),)

3. Image图片组件的使用

3.1 Image Widget的集中加入形式

  1. Image.asset: 加载资源图片,会使打包时包体积过大
  2. Image.network: 网络资源图片,经常换的或者动态图片
  3. Image.file: 本地图片,比如相机照相后的图片预览

3.2 Fit 属性的使用

Fit 属性是说图片平铺的效果设置,用BoxFit组件来设置,主要有这几种样式:

  1. BoxFit.fill: 填充整个图片视图
    在这里插入图片描述

  2. BoxFit.contain :根据图片的比例完全展示在视图上,不会被裁剪。
    在这里插入图片描述

  3. BoxFit.cover: 根据图片的比例,填充这个视图,会被裁剪。
    在这里插入图片描述

  4. BoxFit.fitWidth 根据图片的宽度自适应视图
    在这里插入图片描述

  5. BoxFit.fitHeight 根据图片的高度,自适应视图
    在这里插入图片描述

3.3 图片背景色

  1. color: 设置背景色
  2. colorBlendMode: 混合模式, 用BlendMode组件来实现

代码案例:

child: Image.network('https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2024%2F1129%2F27ab50dfj00snowf20035d200u000tug008t008r.jpg&thumbnail=660x2147483647&quality=80&type=jpg',scale: 2.0,fit: BoxFit.fitHeight,color: Colors.greenAccent,colorBlendMode: BlendMode.difference,)

3.4 repeat属性的使用

需要使用ImageRepeat组件来实现,常用的模式有:

  1. ImageRepeat.repeat
  2. ImageRepeat.repeatX
  3. ImageRepeat.repeatY

3.5 本地图片的使用

首先,在项目的根目录中,添加一个文件夹, 命名为images,然后把图片拖进去,如下图:
在这里插入图片描述

其次,项目的pubspec.yaml的文件中,配置本地图片,如下图:
在这里插入图片描述

最后,在代码中引用Image.asset('images/picture_1.png'),代码如下:

import 'package:flutter/material.dart';void main() {runApp(MaterialApp(title: "图片本地展示",home: FirstPage()));
}class FirstPage extends StatelessWidget {const FirstPage({super.key});Widget build(BuildContext context) {return Scaffold(appBar: AppBar(title: Text("图片本地加载")),body: Center(// 引用本地图片的代码child: Image.asset('images/picture_1.png'),),);}
}

4. ListView 的初级使用

4.1 竖向列表的使用

代码案例1:

import 'package:flutter/material.dart';void main() => runApp(MyApp());class MyApp extends StatelessWidget {Widget build(BuildContext context) {return MaterialApp(title: 'Flutter 的demo',home: Scaffold(appBar: AppBar(title: Text('ListView Widget'),),body: ListView(children: <Widget>[ListTile(leading: Icon(Icons.accessible_forward_outlined),title: Text('标题提标题'),),ListTile(leading: Icon(Icons.accessibility_new_outlined),title: Text('标题提标题'),),ListTile(leading: Icon(Icons.access_alarm),title: Text('标题提标题'),),],),),);}
}

代码案例2:

import 'package:flutter/material.dart';void main() => runApp(MyApp());class MyApp extends StatelessWidget {Widget build(BuildContext context) {return MaterialApp(title: 'Flutter 的demo',home: Scaffold(appBar: AppBar(title: Text('ListView Widget'),),body: ListView(children: <Widget>[Image.network('https://pic.rmb.bdstatic.com/bjh/news/0fc6b71c59a69f39cf2e1244d10eaedc.jpeg'),Image.network('https://img1.baidu.com/it/u=1368815763,3761060632&fm=253&fmt=auto&app=138&f=JPEG?w=760&h=434'),Image.network('https://i-blog.csdnimg.cn/blog_migrate/41635df939e6dd13c6d5e2af785d358b.jpeg'),Image.network('https://img2.baidu.com/it/u=2848534206,1976619941&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=896'),],),),);}
}

效果图:
在这里插入图片描述

4.2 横向列表的使用

scrollDirection这个属性来设置列表滚动的方向:

  1. Axis.horizontal 横向滚动
  2. Axis.vertical 纵向滚动

4.3 动态列表的使用

代码案例:

import 'package:flutter/material.dart';void main() {runApp(MyApp(items: List<String>.generate(100,(i) => 'Heading $i')),);
}class MyApp extends StatelessWidget {final List<String> items;const MyApp({super.key, required this.items});Widget build(BuildContext context) {final itemList = items; // 如果items为null,则使用默认值return MaterialApp(home: Scaffold(appBar: AppBar(title: Text('Example App')),body: ListView.builder(itemCount: itemList.length,itemBuilder: (context, index) {return ListTile(title: Text(itemList[index]));},),),);}
}

5. 网络布局的使用

主要用GridView组件来实现,GridView提供了几种创建方式:

  1. GridView()
  2. GridView.builder()
  3. GridView.custom()
  4. GridView.count()

常用的属性有:

crossAxisCount: 3, 每一行展示几个item
mainAxisSpacing: 2.0, 上下的间距
crossAxisSpacing: 2.0, 左右的间距
childAspectRatio: 0.75 长和宽的比,用来设置每个子视图的大小

代码使用案例:

import 'package:flutter/material.dart';void main() {runApp(FilmExample());
}class FilmExample extends StatelessWidget {Widget build(BuildContext context) {return MaterialApp(title: "电影海报实例",home: Scaffold(appBar: AppBar(title: Text("电影海报实例"),),body: GridViewDelegateTest(),));}
}// GridViewDelegate 的使用案例
class GridViewDelegateTest extends StatelessWidget {Widget build(BuildContext context) {return GridView(gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3,  // 每一行展示几个itemmainAxisSpacing: 2.0,  // 上下的间距crossAxisSpacing: 2.0, // 左右的间距childAspectRatio: 0.75 // 长宽比),children: [Image.network('https://pic.rmb.bdstatic.com/bjh/news/0fc6b71c59a69f39cf2e1244d10eaedc.jpeg', fit: BoxFit.cover),Image.network('https://img1.baidu.com/it/u=1368815763,3761060632&fm=253&fmt=auto&app=138&f=JPEG?w=760&h=434', fit: BoxFit.cover),Image.network('https://i-blog.csdnimg.cn/blog_migrate/41635df939e6dd13c6d5e2af785d358b.jpeg', fit: BoxFit.cover),Image.network('https://pic.rmb.bdstatic.com/bjh/news/0fc6b71c59a69f39cf2e1244d10eaedc.jpeg', fit: BoxFit.cover),Image.network('https://pic.rmb.bdstatic.com/bjh/news/0fc6b71c59a69f39cf2e1244d10eaedc.jpeg', fit: BoxFit.cover),Image.network('https://img1.baidu.com/it/u=1368815763,3761060632&fm=253&fmt=auto&app=138&f=JPEG?w=760&h=434', fit: BoxFit.cover),Image.network('https://pic.rmb.bdstatic.com/bjh/news/0fc6b71c59a69f39cf2e1244d10eaedc.jpeg', fit: BoxFit.cover),Image.network('https://pic.rmb.bdstatic.com/bjh/news/0fc6b71c59a69f39cf2e1244d10eaedc.jpeg', fit: BoxFit.cover),Image.network('https://img2.baidu.com/it/u=2848534206,1976619941&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=896', fit: BoxFit.cover),Image.network('https://pic.rmb.bdstatic.com/bjh/news/0fc6b71c59a69f39cf2e1244d10eaedc.jpeg', fit: BoxFit.cover),Image.network('https://img1.baidu.com/it/u=1368815763,3761060632&fm=253&fmt=auto&app=138&f=JPEG?w=760&h=43', fit: BoxFit.cover),Image.network('https://pic.rmb.bdstatic.com/bjh/news/0fc6b71c59a69f39cf2e1244d10eaedc.jpeg', fit: BoxFit.cover),Image.network('https://img2.baidu.com/it/u=2848534206,1976619941&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=896', fit: BoxFit.cover),Image.network('https://i-blog.csdnimg.cn/blog_migrate/41635df939e6dd13c6d5e2af785d358b.jpeg', fit: BoxFit.cover),Image.network('https://pic.rmb.bdstatic.com/bjh/news/0fc6b71c59a69f39cf2e1244d10eaedc.jpeg', fit: BoxFit.cover),Image.network('https://img2.baidu.com/it/u=2848534206,1976619941&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=896', fit: BoxFit.cover),Image.network('https://i-blog.csdnimg.cn/blog_migrate/41635df939e6dd13c6d5e2af785d358b.jpeg', fit: BoxFit.cover),],);}
}

效果图:
在这里插入图片描述

6. 水平方向的布局案例

水平方向布局的设置,用Row的组件来设置,其中有个小知识点:Expanded组件,是填充组件:

如果设置了3个Expanded,表示将三个视图将屏幕的宽度3等份平铺。
如果三个视图中,中间的视图用Expanded包裹着,那第一个和第三个视图按照自身的大小展示,第二个视图填充剩余的宽度。

代码案例:

import 'package:flutter/material.dart';void main() {runApp(MyExampleApp());
}class MyExampleApp extends StatelessWidget {Widget build(BuildContext context) {return MaterialApp(title: "布局RowWidge",home: Scaffold(appBar: AppBar(title: Text("布局RowWidge案例"),),body: Row(children: [Expanded(child: ElevatedButton(onPressed: (){},style: ElevatedButton.styleFrom(foregroundColor: Colors.white,backgroundColor: Colors.redAccent, // foreground (text) color),child: Text("红色按钮"))),Expanded(child: ElevatedButton(onPressed: (){},style: ElevatedButton.styleFrom(foregroundColor: Colors.white,backgroundColor: Colors.orangeAccent, // foreground (text) color),child: Text("橙色按钮"))),Expanded(child: ElevatedButton(onPressed: (){},style: ElevatedButton.styleFrom(foregroundColor: Colors.white,backgroundColor: Colors.blueAccent, // foreground (text) color),child: Text("蓝色按钮"))),],),),);}
}

7. 垂直方向的布局案例

Column组件来实现垂直方向的布局,代码案例:

import 'package:flutter/material.dart';void main() {runApp(MyExampleApp());
}// ---布局ColumnWidge的案例---
class MyExampleApp extends StatelessWidget {Widget build(BuildContext context) {return MaterialApp(title: "垂直方向布局案例",home: Scaffold(appBar: AppBar(title: Text("垂直方向布局案例"),),body: Column(mainAxisAlignment: MainAxisAlignment.center,  // 主轴对齐方式:垂直的crossAxisAlignment: CrossAxisAlignment.center,  // 副轴对齐方式:左右的children: [Text('111111'),Expanded(child: Text('222222')),Text('333333333333')],),),);}
}

8. 层叠布局案例

8.1 只有两个视图的stack的使用方法

Stack组件来实现,最少需要两个子视图,其中有个属性alignment是子控件内部按照什么对齐方式对齐:

最小是0,最大是1, 是相对于stack内部空间中,最大视图的位置来说的

代码案例:

import 'package:flutter/material.dart';void main() {runApp(MyExampleApp());
}class MyExampleApp extends StatelessWidget {Widget build(BuildContext context) {var stack = Stack(// 内部控件的对齐方式,最小是0,最大是1, 是相对于stack内部空间中,最大视图的位置来说的alignment: FractionalOffset(0.5, 0.8),  children: [CircleAvatar(backgroundImage: NetworkImage('https://pic.rmb.bdstatic.com/bjh/news/0fc6b71c59a69f39cf2e1244d10eaedc.jpeg'),radius: 100.0,),Container(decoration: BoxDecoration(color: Colors.blueAccent),padding: EdgeInsets.all(5.0),child: Text('ZhuZhu'),)],);return MaterialApp(title: "布局案例",home: Scaffold(appBar: AppBar(title: Text("层叠布局"),),body: Center(child: stack,),),);}
}

效果图:
在这里插入图片描述

8.2 如果stack的子视图多于2个的使用方法

如果stack子视图大于2个,那么用alignment 的对齐方式来布局,就非常的不优化,此时,可以选择Positioned组件来设置布局,代码如下:

import 'package:flutter/material.dart';void main() {runApp(MyExampleApp());
}class MyExampleApp extends StatelessWidget {Widget build(BuildContext context) {var stack = Stack(// 内部控件的对齐方式,最小是0,最大是1, 是相对于stack内部空间中,最大视图的位置来说的alignment: FractionalOffset(0.5, 0.8),  children: [CircleAvatar(backgroundImage: NetworkImage('https://pic.rmb.bdstatic.com/bjh/news/0fc6b71c59a69f39cf2e1244d10eaedc.jpeg'),radius: 100.0,),Positioned(top: 10.0,left: 10.0,child: Container(decoration: BoxDecoration(color: Colors.blueAccent),padding: EdgeInsets.all(5.0),child: Text("zhuzhu"),)),Positioned(bottom: 10.0,right: 10.0,child: Container(decoration: BoxDecoration(color: Colors.deepOrange),padding: EdgeInsets.all(5.0),child: Text("技术猪"),)),],);return MaterialApp(title: "布局案例",home: Scaffold(appBar: AppBar(title: Text("层叠布局"),),body: Center(child: stack,),),);}
}

效果图如下:
在这里插入图片描述

8. 卡片布局案例

Card组件来实现,代码如下:

import 'package:flutter/material.dart';void main() {runApp(MyExampleApp());
}class MyExampleApp extends StatelessWidget {Widget build(BuildContext context) {var card = Card(child: Column(children: [ListTile(title: Text("福建省厦门市湖里区", style: TextStyle(fontWeight: FontWeight.w700)),subtitle: Text("zhuzhu:15100001234"),leading: Icon(Icons.account_box, color: Colors.blueAccent),),Divider(),ListTile(title: Text("北京市海淀区中关村", style: TextStyle(fontWeight: FontWeight.w700)),subtitle: Text("guoguo:15100001234"),leading: Icon(Icons.account_box, color: Colors.blueAccent),),Divider(),ListTile(title: Text("上海市浦江区", style: TextStyle(fontWeight: FontWeight.w700)),subtitle: Text("xuexue:15100001234"),leading: Icon(Icons.account_box, color: Colors.blueAccent),),],),);return MaterialApp(title: "布局案例",home: Scaffold(appBar: AppBar(title: Text("层叠布局"),),body: Center(child: card,),),);}

效果图:
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/68046.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

什么是COLLATE排序规则?

在当今数字化世界中&#xff0c;数据的整理、比较和排序是至关重要的。在数据库管理和编程语言中&#xff0c;我们经常需要对字符串进行排序&#xff0c;以展示或处理信息。为了实现这一点&#xff0c;各种系统和工具提供了排序规则&#xff0c;其中COLLATE排序规则就是其中的一…

打印输入单词字符数量统计直方图-C语言第二版

1. 编程要求 多年前写过一篇用 C 语言实现打印单词字符数量统计的直方图的文章, 现在看上去有些混乱, 对一些任务划分不清晰, 全部混在一起. 于是重写了这个编程题, 希望可以给初学者一些参考, 并且我分别用 C, C, Java, Python 四种语言完成了这道编程题, 有兴趣的可以看我另…

【QT】-explicit关键字

explicit explicit 是一个 C 关键字&#xff0c;用于修饰构造函数。它的作用是防止构造函数进行隐式转换。 为什么需要 explicit&#xff1f; 在没有 explicit 的情况下&#xff0c;构造函数可以用于隐式类型转换。这意味着&#xff0c;如果你有一个接受某种类型的参数的构造…

【C++模板】:如何判断自定义类型是否实现某个函数

一、引子 偶尔我们会面对这样的尴尬的场景&#xff0c;我们需要显示的去判断在某个自定义类型中&#xff0c;是否已经提供了我们期待的API接口&#xff0c;以避免产生“莫须有”的错误。阁下该如何破解此问题&#xff01; 这里&#xff0c;直接给出一种通用的方法&#xff0c;…

认识Django项目模版文件——Django学习日志(二)

1.默认文件介绍 └── djangoproject1/├── djangoproject1/│ ├── urls.py [URL和函数的对应关系]【常用文件】│ ├── settings.py [项目配置文件]【常用文件】│ ├── _init_.py│ ├── wsgi.py [接受网络请求] 【不要动】│ └──…

【JS逆向】前端加密对抗基础

目录 逆向基础断掉调试基本常见的加解密方式 encrypt-labs靶场搭建过程靶场基本教程AES加密key前端体现(固定key)AES服务端获取keyRSA非对称加密DES加密存在规律key明文加签sign加签key在服务端signAESRAS组合 逆向基础 断掉调试 通过浏览器站点控制台(F12)&#xff0c;进行断…

C# 多线程同步(Mutex | Semaphore)

Mutex: 用于保护临界区&#xff0c;确保同一时间只有一个线程能够访问共享资源&#xff1b; Semaphore: 允许同时有多个线程访问共享资源&#xff0c;但会限制并发访问的数量。 Mutex运行输出 Semaphore运行输出 namespace SyncThreadDemo {internal class Program{static stri…

复位信号的同步与释放(同步复位、异步复位、异步复位同步释放)

文章目录 背景前言一、复位信号的同步与释放1.1 同步复位1.1.1 综述1.1.2 优缺点 1.2 recovery time和removal time1.3 异步复位1.3.1 综述1.3.2 优缺点 1.4 同步复位 与 异步复位1.5 异步复位、同步释放1.5.1 总述1.5.2 机理1.5.3 复位网络 二、思考与补充2.1 复…

git远程仓库如何修改

1.需要做的事情&#xff1a;把git的远程仓库修改掉&#xff0c;在git创建一个自己的仓库 如果你是私有化的话&#xff0c;可以生成一个自己token令牌也可以。到时候push的时候会让你登录你就可以输入你的token令牌和用户名。 2.查看当前仓库的远程地址是不是自己的 &#xff…

mysql 学习3 SQL语句--整体概述。SQL通用语法;DDL创建数据库,查看数据库,删除数据库,使用数据库;

SQL通用语法 SQL语句分类 DDL data definition language : 用来创建数据库&#xff0c;创建表&#xff0c;创建表中的字段&#xff0c;创建索引。因此成为 数据定义语言 DML data manipulation language 有了数据库和表以及字段后&#xff0c;那么我们就需要给这个表中 添加数…

【xcode 16.2】升级xcode后mac端flutter版的sentry报错

sentry_flutter 7.11.0 报错 3 errors in SentryCrashMonitor_CPPException with the errors No type named terminate_handler in namespace std (line 60) and No member named set_terminate in namespace std 替换sentry_flutter版本为&#xff1a; 8.3.0 从而保证oc的…

【回忆迷宫——处理方法+DFS】

题目 代码 #include <bits/stdc.h> using namespace std; const int N 250; int g[N][N]; bool vis[N][N]; int dx[4] {0, 0, -1, 1}; int dy[4] {-1, 1, 0, 0}; int nx 999, ny 999, mx, my; int x 101, y 101; //0墙 (1空地 2远方) bool jud(int x, int y) {if…

wireshark工具简介

目录 1 wireshark介绍 2 wireshark抓包流程 2.1 选择网卡 2.2 停止抓包 2.3 保存数据 3 wireshark过滤器设置 3.1 显示过滤器的设置 3.2 抓包过滤器 4 wireshark的封包列表与封包详情 4.1 封包列表 4.2 封包详情 参考文献 1 wireshark介绍 wireshark是非常流行的网络…

⽤vector数组实现树的存储(孩⼦表示法)c++

在我们遇到的算法题中&#xff0c; ⼀般给出的树结构都是有编号的&#xff0c;这样会简化我们之后存储树的操作 &#xff0c;⼀般提供两个信息&#xff1b; 结点的个数 n;n-1条x结点与y结点相连的边 题⽬描述: ⼀共9个结点셈 1号结点为根节点&#xff0c;接下来8⾏&#xff…

C语言-内存管理

1、malloc()函数 用于动态分配一块指定大小的内存&#xff0c;并返回指向这块内存的指针。如果分配失败&#xff0c; 返回 NULL。 int* ptr (int*)malloc(sizeof(int) * 10); // 分配一个包含 10 个整数的内存 if (ptr NULL) {printf("Memory allocation failed!\n&q…

蓝桥杯lesson3---string的使用

&#x1f308;个人主页&#xff1a;羽晨同学 &#x1f4ab;个人格言:“成为自己未来的主人~” string的概念 string字符串是一种更加高级的封装&#xff0c;string字符串中包含了大量的方法&#xff0c;这些方法使得字符串的操作变得更加简单&#xff0c;string的使用&…

動態住宅IP提升網站訪問成功率

動態住宅IP通常與普通家庭用戶的網路連接相關聯。這種IP地址的特點在於&#xff0c;它是動態變化的&#xff0c;用戶在每次連接時可能會獲得不同的IP地址。這與靜態IP形成了鮮明對比&#xff0c;後者在連接期間保持不變。傳統上&#xff0c;IP地址分為住宅IP和數據中心IP兩類。…

进制之间转换

「 一、十进制 二进制 」 1.十进制转二进制&#xff1a;一直除以2直到商为0&#xff0c;再反向取余数。 例&#xff1a;13&#xff08;十进制&#xff09;转1101&#xff08;二进制&#xff09; 2.二进制转十进制:最后一位数开始是2^0&#xff0c;然后一直按照指数递增的方式…

3b1b线性代数基础

零、写在前面 3b1b之前没认真看&#xff0c;闲了整理整理。 一、向量 学习物理的时候&#xff0c;向量是空间中的箭头。由其方向和长度决定。 学习数据结构的时候&#xff0c;向量是有序的数字列表。向量的每一维度有着不同含义。 线性代数中&#xff0c;我们通常认为**向量…

Consul持久化配置报错1067---consul_start

报错都是文件写的有问题或者格式问题&#xff0c;直接复制我的这个改改地址就行 先创建文本文件consul_start.txt--->再复制代码保存---->再把.txt改成.bat 持久化存储的地址在&#xff1a;mydata 注&#xff1a;D:\consul\consul_1.20.2_windows_386改成自己consul的…