c# 委托 事件 lambda表达式

委托

C/C++中的函数指针实例:

typedef int (*Calc)(int a, int b); //这里必须加括号
int Add(int a, int b)
{return a + b;
}
int Sub(int a, int b)
{return a - b;
}
int main()
{int x = 100;int y = 200;int z = 0;Calc funcPoint1 = &Add;Calc funcPoint2 = &Sub;z = funcPoint1(x, y);cout << z << endl;z = funcPoint2(x, y);cout << z << endl;
}

委托实例

class Program{static void Main(string[] args){Calculator c = new Calculator();//Action委托:没有返回参数Action action = new Action(c.PrintInfo);c.PrintInfo();action.Invoke();action();//Func委托:有返回参数Func<int, int, int> f = new Func<int, int, int>(c.Add);Func<int, int, int> f2 = new Func<int, int, int>(c.Sub);Console.WriteLine(f(1, 2));Console.WriteLine(f.Invoke(1, 2));Console.WriteLine(f2(1, 2));Console.WriteLine(f2.Invoke(1, 2));}}class Calculator{public void PrintInfo(){Console.WriteLine("this class has 3 methods");}public int Add(int a, int b){return a + b;}public int Sub(int a, int b){return a - b;}}
class Program
{static void Main(string[] args){Action<string> action = new Action<string>(SayHello);action("Tim");}static void SayHello(string name){Console.WriteLine($"Hello, {name1}!");}
}
//可以用var关键字来缩短代码:
class Program
{static void Main(string[] args){var action = new Action<string, int>(SayHello);action("Tim");}static void SayHello(string name, int rount){for(int i=0; i<round; ++i){Console.WriteLine($"Hello, {name1}!");}}
}

Console.WriteLine后面 “$”的作用

//复杂麻烦的写法string str1 = "my name is " + name + ",my age is " + age + ".";//使用Format的写法string str2 = string.Format("my name is {0},my age is {1}.", name, age);//使用$语法糖的写法string str3 = $"my name is {name},my age is {age}.";

public delegate double Calc(double x, double y);class Program{static void Main(string[] args){Calculator calculator = new Calculator();double x = 200;double y = 100;double z;Calc calc1 = new Calc(calculator.Add);Calc calc2 = new Calc(calculator.Sub);Calc calc3 = new Calc(calculator.Mul);Calc calc4 = new Calc(calculator.Div);z = calc1(x, y);Console.WriteLine(z);z = calc2.Invoke(x, y);Console.WriteLine(z);z = calc3.Invoke(x, y);Console.WriteLine(z); z = calc4.Invoke(x, y);Console.WriteLine(z);}}class Calculator{public double Add(double a, double b){return a + b;}public double Sub(double a, double b){return a - b;}public double Mul(double a, double b){return a * b;}public double Div(double a, double b){return a / b;}}

模板方法案例

class Program
{static void Main(string[] args){ProductFactory pf = new ProductFactory();WrapFactory wf = new WrapFactory();Func<Product> func1 = new Func<Product>(pf.MakePizza);Func<Product> func2 = new Func<Product>(pf.MakeToyCar);Box box1 = wf.WrapProduct(func1);Box box2 = wf.WrapProduct(func2);Console.WriteLine(box1.Product.Name);Console.WriteLine(box2.Product.Name);}
}
class Product
{public string Name { get; set; }
}
class Box
{public Product Product { get; set; }
}
class WrapFactory
{public Box WrapProduct(Func<Product> getProduct){Box box = new Box();box.Product = getProduct.Invoke();return box;}
}
class ProductFactory
{public Product MakePizza(){Product product = new Product();product.Name = "Pizza";return product;}public Product MakeToyCar(){Product product = new Product();product.Name = "Toy Car";return product;}
}

回调方法案例

class Program
{static void Main(string[] args){ProductFactory pf = new ProductFactory();WrapFactory wf = new WrapFactory();Func<Product> func1 = new Func<Product>(pf.MakePizza);Func<Product> func2 = new Func<Product>(pf.MakeToyCar);Logger logger = new Logger();Action<Product> action = new Action<Product>(logger.log);Box box1 = wf.WrapProduct(func1, action);Box box2 = wf.WrapProduct(func2, action);Console.WriteLine(box1.Product.Name);Console.WriteLine(box2.Product.Name);}
}
class Logger
{public void log(Product product){Console.WriteLine("Product {0} created at {1}. Price is {2}.", product.Name, DateTime.UtcNow, product.Price); }
}
class Product
{public string Name { get; set; }public int Price { get; set; }
}
class Box
{public Product Product { get; set; }
}
class WrapFactory
{public Box WrapProduct(Func<Product> getProduct, Action<Product> logCallback){Box box = new Box();Product product = getProduct.Invoke();if(product.Price>=50){logCallback.Invoke(product);}box.Product = product;return box;}
}
class ProductFactory
{public Product MakePizza(){Product product = new Product();product.Name = "Pizza";product.Price = 12;return product;}public Product MakeToyCar(){Product product = new Product();product.Name = "Toy Car";product.Price = 100;return product;}
}

委托的高级使用

多播委托案例

class Program
{static void Main(string[] args){Student stu1 = new Student() { ID=1, PenColor = ConsoleColor.Yellow};Student stu2 = new Student() { ID=1, PenColor = ConsoleColor.Green};Student stu3 = new Student() { ID=1, PenColor = ConsoleColor.Red};Action action1 = new Action(stu1.DoHomeWork);Action action2 = new Action(stu2.DoHomeWork);Action action3 = new Action(stu3.DoHomeWork);//单播委托//action1.Invoke();//action2.Invoke();//action3.Invoke();//多播委托action1 += action2;action1 += action3;action1.Invoke();}
}
class Student
{public int ID { get; set; }public ConsoleColor PenColor { get; set; }public void DoHomeWork(){for (int i = 0; i < 5; i++){Console.ForegroundColor = this.PenColor;Console.WriteLine("Student {0} doing homework {1} hour(s).", this.ID, i);Thread.Sleep(1000);}}
}

隐式异步调用 -- BeginInvoke

class Program
{static void Main(string[] args){Student stu1 = new Student() { ID=1, PenColor = ConsoleColor.Yellow};Student stu2 = new Student() { ID=2, PenColor = ConsoleColor.Green};Student stu3 = new Student() { ID=3, PenColor = ConsoleColor.Red};Action action1 = new Action(stu1.DoHomeWork);Action action2 = new Action(stu2.DoHomeWork);Action action3 = new Action(stu3.DoHomeWork);//隐式异步调用action1.BeginInvoke(null, null);action2.BeginInvoke(null, null);action3.BeginInvoke(null, null);for (int i = 0; i < 10; i++){Console.ForegroundColor = ConsoleColor.Cyan;Console.WriteLine("Main thread {0}.", i);Thread.Sleep(1000);}}
}
class Student
{public int ID { get; set; }public ConsoleColor PenColor { get; set; }public void DoHomeWork(){for (int i = 0; i < 5; i++){Console.ForegroundColor = this.PenColor;Console.WriteLine("Student {0} doing homework {1} hour(s).", this.ID, i);Thread.Sleep(1000);}}
}

显式异步调用

注:ctrl+. 给没有定义命名空间的类添加命名空间

class Program{static void Main(string[] args){Student stu1 = new Student() { ID=1, PenColor = ConsoleColor.Yellow};Student stu2 = new Student() { ID=2, PenColor = ConsoleColor.Green};Student stu3 = new Student() { ID=3, PenColor = ConsoleColor.Red};//显式异步调用Thread thread1 = new Thread(new ThreadStart(stu1.DoHomeWork));Thread thread2 = new Thread(new ThreadStart(stu2.DoHomeWork));Thread thread3 = new Thread(new ThreadStart(stu3.DoHomeWork));thread1.Start();thread2.Start();thread3.Start();//使用task显式异步调用Action action1 = new Action(stu1.DoHomeWork);Action action2 = new Action(stu2.DoHomeWork);Action action3 = new Action(stu3.DoHomeWork);Task task1 = new Task(action1);Task task2 = new Task(action2);Task task3 = new Task(action3);task1.Start();task2.Start();task3.Start();for (int i = 0; i < 10; i++){Console.ForegroundColor = ConsoleColor.Cyan;Console.WriteLine("Main thread {0}.", i);Thread.Sleep(1000);}}}class Student{public int ID { get; set; }public ConsoleColor PenColor { get; set; }public void DoHomeWork(){for (int i = 0; i < 5; i++){Console.ForegroundColor = this.PenColor;Console.WriteLine("Student {0} doing homework {1} hour(s).", this.ID, i);Thread.Sleep(1000);}}}

可以使用接口来取代委托

以上面的回调方法中的例子作为改进:

class Program
{static void Main(string[] args){IProductFactory pizzaFactory = new PizzaFactory();IProductFactory toycarFactory = new ToycarFactory();WrapFactory wf = new WrapFactory();Box box1 = wf.WrapProduct(pizzaFactory);Box box2 = wf.WrapProduct(toycarFactory);Console.WriteLine(box1.Product.Name);Console.WriteLine(box2.Product.Name);}
}
interface IProductFactory
{Product Make();
}
class PizzaFactory : IProductFactory
{public Product Make(){Product product = new Product();product.Name = "Pizza";product.Price = 12;return product;}
}
class ToycarFactory : IProductFactory
{public Product Make(){Product product = new Product();product.Name = "Toy Car";product.Price = 100;return product;}
}
class Product
{public string Name { get; set; }public int Price { get; set; }
}
class Box
{public Product Product { get; set; }
}
class WrapFactory
{public Box WrapProduct(IProductFactory productFactory){Box box = new Box();Product product = productFactory.Make();box.Product = product;return box;}
}

自己定义委托类型

class Program
{static void Main(string[] args){MyDele dele1 = new MyDele(M1);Student stu = new Student();//dele1 += stu.SayHello;//同上dele1 += (new Studnet()).SayHello;//dele1.Invoke();//同上,与上面相比下面直接调用方法更常用。dele1();}static void M1(){Console.Write("M1 is called");}class Student{public void SayHello(){Concole.WriteLine("Hello, I'm a student!");}}delegate void MyDele();
}

自定义泛型委托

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace DelegateExample
{class Program{static void Main(string[] args){MyDele<int> myDele = new MyDele<int>(Add);int addRed = myDele(2, 4);Console.WriteLine(addRed);MyDele<double> myDele2 = new MyDele<double>(Mul);double mulRed = myDele2(2.2, 2.2);Console.WriteLine(mulRed);//查看委托是否是类Console.WriteLine(myDele.GetType().IsClass);}static int Add(int x, int y){return x + y;}static double Mul(double x, double y){return x * y;}}delegate T MyDele<T>(T a, T b);
}

事件

事件的概念

微软把这种经由事件发送出来的与事件本身相关的数据称为:事件参数

根据通知和事件参数来采取行动的这种行为称为响应事件或处理事件。处理事件时具体所做的事情就叫做事件处理器

事件的应用

案例1.
class Program{static void Main(string[] args){//timer: 事件的拥有者Timer timer = new Timer();timer.Interval = 1000;// boy和girl: 事件的响应者Boy boy = new Boy();//timer.Elapsed: 事件成员; boy.Action: 事件处理器;+=: 事件订阅timer.Elapsed += boy.Action;Girl girl = new Girl();timer.Elapsed += girl.Action;//timer.Enabled = true;timer.Start();Console.ReadLine();}}class Boy{internal void Action(object sender, ElapsedEventArgs e){Console.WriteLine("jump");}}class Girl{internal void Action(object sender, ElapsedEventArgs e){Console.WriteLine("Sing");}}
案例2:图一颗星方式
class Program{static void Main(string[] args){//form: 事件拥有者Form form = new Form();//controller: 事件响应者Controller controller = new Controller(form);form.ShowDialog();}}class Controller{private Form form;public Controller(Form form){this.form = form;//this.form.Click: 事件; +=: 事件订阅this.form.Click += this.FormClicked;}//FormClicked:事件处理器private void FormClicked(object sender, EventArgs e){this.form.Text = DateTime.Now.ToString();}}
案例3:图两颗星方式
class Program{static void Main(string[] args){//form: 事件拥有者和响应者MyForm form = new MyForm();form.Click += form.FormClicked;form.ShowDialog();}}class MyForm : Form{internal void FormClicked(object sender, EventArgs e){this.Text = DateTime.Now.ToString();}}
案例4:图三颗星方式
class Program{static void Main(string[] args){//form: 事件拥有者和响应者MyForm form = new MyForm();        form.ShowDialog();}}this Form: 响应者class MyForm : Form{private TextBox textBox;private Button button;public MyForm(){this.textBox = new TextBox();//this.button: 拥有者this.button = new Button();this.Controls.Add(this.textBox);this.Controls.Add(this.button);this.button.Click += this.ButtonClicked;this.button.Text = "say hello";this.button.Top = 50;}public void ButtonClicked(object sender, EventArgs e){this.textBox.Text = "Hello World!!!!!!!!!!!!!!!!!!";}}
在窗体应用程序中,使用事件的五种方法
namespace EventWindowsForms
{public partial class Form1 : Form{public Form1(){InitializeComponent();//button2. 方法2. 手动订阅this.button2.Click += buttonClick;//button3. 方法3.委托this.button3.Click += new EventHandler(buttonClick);//button4. 方法4. 旧式委托this.button4.Click += delegate (object sender, EventArgs e){this.myTextBox.Text = "button4Clicked!";};//button5. 方法5. lambda表达式this.button5.Click += (sender, e) =>{this.myTextBox.Text = "button5Clicked!";};}//button1. 方法1.直接在设计中双击click自动生成订阅private void buttonClick(object sender, EventArgs e){if(sender==button1){this.myTextBox.Text = "hello!";}if(sender==button2){this.myTextBox.Text = "world!";}if(sender==button3){this.myTextBox.Text = "My.Okey!";}}}
}

事件的定义

事件声明的完整格式

namespace FullFormOfEvent
{class Program{static void Main(string[] args){Customer customer = new Customer();Waiter waiter = new Waiter();customer.Order += waiter.Action;//一定是事件拥有者的内部逻辑触发了该事件customer.Action();customer.PayThisBill();}}public class OrderEventArgs:EventArgs{public string DishName { get; set; }public string Size { get; set; }}//声明委托类型 为声明的order事件用的//当一个委托专门用来声明事件时,名称一般为事件名+EventHandlerpublic delegate void OrderEventHandler(Customer customer, OrderEventArgs e);public class Customer{//声明一个委托类型的字段 引用事件处理器的private OrderEventHandler orderEventHandler;public event OrderEventHandler Order{add{this.orderEventHandler += value;}remove{this.orderEventHandler -= value;}}public double Bill { get; set; }public void PayThisBill(){Console.WriteLine("I will pay ${0}.", this.Bill);}//事件要通过委托来做一个约束,这个委托//既规定了事件发送什么消息给事件的响应者//也规定了事件的响应者能收到什么样的消息//事件响应者的事件处理器必须能够跟约束匹配上,才能订阅事件//当事件的响应者向事件的拥有者提供了能够匹配这个事件的事件处理器之后,//需要将此处理器保存或记录下来,能够记录或引用方法的任务只有//引用委托的实例才能够做到。//事件这种成员,无论从表层约束上来讲,还是从底层实现来讲,都依赖委托类型public void WalkIn(){Console.WriteLine("Walk into the restaurant.");}public void SitDown(){Console.WriteLine("Sit down.");}public void Think(){for (int i = 0; i < 5; i++){Console.WriteLine("Let me think。。。");Thread.Sleep(1000);}if(this.orderEventHandler!=null){OrderEventArgs e = new OrderEventArgs();e.DishName = "Kongpao Chicken";e.Size = "large";this.orderEventHandler.Invoke(this, e);}}public void Action(){Console.ReadLine();this.WalkIn();this.SitDown();this.Think();}}public class Waiter{internal void Action(Customer customer, OrderEventArgs e){Console.WriteLine("I will serve you the dish - {0}.", e.DishName);double price = 10;switch (e.Size){case "small":price = price * 0.5;break;case "large":price = price * 1.5;break;default:break;}customer.Bill += price;}}
}

事件声明的简略格式

只修改了两个部分

namespace FullFormOfEvent
{class Program{static void Main(string[] args){Customer customer = new Customer();Waiter waiter = new Waiter();customer.Order += waiter.Action;//一定是事件拥有者的内部逻辑触发了该事件customer.Action();customer.PayThisBill();}}public class OrderEventArgs:EventArgs{public string DishName { get; set; }public string Size { get; set; }}//声明委托类型 为声明的order事件用的//当一个委托专门用来声明事件时,名称一般为事件名+EventHandlerpublic delegate void OrderEventHandler(Customer customer, OrderEventArgs e);public class Customer{
// 修改1public event OrderEventHandler Order;public double Bill { get; set; }public void PayThisBill(){Console.WriteLine("I will pay ${0}.", this.Bill);}public void WalkIn(){Console.WriteLine("Walk into the restaurant.");}public void SitDown(){Console.WriteLine("Sit down.");}public void Think(){for (int i = 0; i < 5; i++){Console.WriteLine("Let me think。。。");Thread.Sleep(1000);}
//修改2//和详细声明相比,现在用了一个事件的名字取代了过去这个字段上的名字//之前的委托类型字段还在,只不过没有出现在代码中if(this.Order!=null){OrderEventArgs e = new OrderEventArgs();e.DishName = "Kongpao Chicken";e.Size = "large";this.Order.Invoke(this, e);}}public void Action(){Console.ReadLine();this.WalkIn();this.SitDown();this.Think();}}public class Waiter{internal void Action(Customer customer, OrderEventArgs e){Console.WriteLine("I will serve you the dish - {0}.", e.DishName);double price = 10;switch (e.Size){case "small":price = price * 0.5;break;case "large":price = price * 1.5;break;default:break;}customer.Bill += price;}}
}

省去了委托类型的声明,而是使用了通用的EventHandler

namespace FullFormOfEvent
{class Program{static void Main(string[] args){Customer customer = new Customer();Waiter waiter = new Waiter();customer.Order += waiter.Action;//一定是事件拥有者的内部逻辑触发了该事件customer.Action();customer.PayThisBill();}}public class OrderEventArgs:EventArgs{public string DishName { get; set; }public string Size { get; set; }}public class Customer{//省去了委托类型的声明,而是使用了通用的EventHandlerpublic event EventHandler Order;public double Bill { get; set; }public void PayThisBill(){Console.WriteLine("I will pay ${0}.", this.Bill);}public void WalkIn(){Console.WriteLine("Walk into the restaurant.");}public void SitDown(){Console.WriteLine("Sit down.");}public void Think(){for (int i = 0; i < 5; i++){Console.WriteLine("Let me think。。。");Thread.Sleep(1000);}//和详细声明相比,现在用了一个事件的名字取代了过去这个字段上的名字//之前的委托类型字段还在,只不过没有出现在代码中if(this.Order!=null){OrderEventArgs e = new OrderEventArgs();e.DishName = "Kongpao Chicken";e.Size = "large";this.Order.Invoke(this, e);}}public void Action(){Console.ReadLine();this.WalkIn();this.SitDown();this.Think();}}public class Waiter{internal void Action(Object sender, EventArgs e){Customer customer = sender as Customer;OrderEventArgs orderInfo = e as OrderEventArgs;Console.WriteLine("I will serve you the dish - {0}.", orderInfo.DishName);double price = 10;switch (orderInfo.Size){case "small":price = price * 0.5;break;case "large":price = price * 1.5;break;default:break;}customer.Bill += price;}}
}

事件与委托的关系

lambda表达式

是匿名和inline方法

//lambda表达式:方法1
Func<int, int, int> func = new Func<int, int, int>((int a, int b)=> { return a + b; });
int res = func(3, 5);
Console.WriteLine($"a+b={res}");
//方法2
func = new Func<int, int, int>((x, y) => { return x * y; });
res = func(3, 5);
Console.WriteLine($"a*b={res}");
//方法3 最常用
func = (x, y) => { return x - y; };
res = func(3, 5);
Console.WriteLine($"a-b={res}");

使用函数来调用lambda表达式(泛型委托的类型参数推断)

DoSomeCalc((a, b)=> { return a + b; }, 100, 200);
static void DoSomeCalc<T>(Func<T, T, T>func, T x, T y)
{T res = func(x, y);Console.WriteLine(res);
}

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

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

相关文章

Android学习之路(19) ListView详解

一.ListView简介 在Android开发中&#xff0c;ListView是一个比较常用的控件。它以列表的形式 展示具体数据内容&#xff0c;并且能够根据数据的长度自适应屏幕显示。 二.ListView简单用法 代码部分 1.布局界面 activity_main.xml 代码&#xff1a; <?xml version"…

新手学习笔记-----编译和链接

目录 1. 翻译环境和运⾏环境 2. 翻译环境&#xff1a;预编译编译汇编链接 2.1 预处理 2.2 编译 2.2.1 词法分析 2.2.2 语法分析 2.2.3 语义分析 2.3 汇编 2.4 链接 3. 运⾏环境 1. 翻译环境和运⾏环境 在ANSI C的任何⼀种实现中&#xff0c;存在两个不同的环境。 第…

LSTM+CRF模型

今天讲讲LSTM和CRF模型&#xff0c;LSTM&#xff08;长短期记忆&#xff09;是一种特殊的循环神经网络&#xff08;RNN&#xff09;模型&#xff0c;用于处理序列数据、时间序列数据和文本数据等。LSTM通过引入门控机制&#xff0c;解决了传统RNN模型在处理长期依赖关系时的困难…

win10 关闭病毒防护

windows10彻底关闭Windows Defender的4种方法 - 知乎

华为鸿蒙手表开发之动态生成二维码

华为鸿蒙手表开发之动态生成二维码 前言&#xff1a; 最近入职新公司&#xff0c;由于之前的哥们临时离职&#xff0c;走得很突然&#xff0c;所以没有任何交接和文档&#xff0c;临时顶上公司手表应用的上架&#xff0c;更换了新的密钥和key之后重新测试功能和流程&#xff…

from PIL import Image,文字成图,ImageFont import jieba分词,input优雅python绘制图片

开始的代码 import os from PIL import Image, ImageDraw, ImageFont import jiebadef generate_image_with_white_bg(text, font_path, output_path):# 设置图片大小和背景颜色image_width 800image_height 600bg_color (255, 255, 255) # 白色# 创建图片对象image Imag…

正点原子嵌入式linux驱动开发——TF-A初探

上一篇笔记中&#xff0c;正点原子的文档简单讲解了一下什么是TF-A&#xff0c;并且也学习了如何编译TF-A。但是TF-A是如何运行的&#xff0c;它的一个运行流程并未涉及。TF-A的详细运行过程是很复杂的&#xff0c;涉及到很多ARM处理器底层知识&#xff0c;所以这一篇笔记的内容…

竞赛选题 机器视觉人体跌倒检测系统 - opencv python

0 前言 &#x1f525; 优质竞赛项目系列&#xff0c;今天要分享的是 &#x1f6a9; 机器视觉人体跌倒检测系统 该项目较为新颖&#xff0c;适合作为竞赛课题方向&#xff0c;学长非常推荐&#xff01; &#x1f947;学长这里给一个题目综合评分(每项满分5分) 难度系数&…

654.最大二叉树

力扣题目地址(opens new window) 给定一个不含重复元素的整数数组。一个以此数组构建的最大二叉树定义如下&#xff1a; 二叉树的根是数组中的最大元素。左子树是通过数组中最大值左边部分构造出的最大二叉树。右子树是通过数组中最大值右边部分构造出的最大二叉树。 通过给…

如何在 Windows 上安装 ONLYOFFICE 协作空间社区版

ONLYOFFICE 协作空间是一个在线协作平台&#xff0c;帮助您更好地与客户、业务合作伙伴、承包商及第三方进行文档协作。今天我们来介绍一下&#xff0c;如何在 Windows 上安装协作空间的自托管版。 ONLYOFFICE 协作空间主要功能 使用 ONLYOFFICE 协作空间&#xff0c;您可以&a…

PowerPoint如何设置密码?

PowerPoint&#xff0c;也就是PPT&#xff0c;是很多人工作中经常用的办公软件&#xff0c;而PPT和Word、Excel等一样可以设置密码保护。 PPT可以设置两种密码&#xff0c;一种是“打开密码”&#xff0c;也就是需要密码才能打开PPT&#xff1b;还有一种是设置成有密码的“只读…

vue ant 隐藏列

vue ant 隐藏列 重要代码 type: FormTypes.hidden{ title: 序号, key: barCode, width: 10%, type: FormTypes.hidden},

ARM-day2

1、1到100累加 .text .global _start_start:MOV r0, #1ADD r1,r0, #1fun:ADD r0,r0,r1ADD r1,r1, #1cmp r1, #0x65moveq PC,LRbl funstop:b stop.end2、思维导图

105.从前序与中序遍历序列构造二叉树

力扣题目链接(opens new window) 根据一棵树的前序遍历与中序遍历构造二叉树。 注意: 你可以假设树中没有重复的元素。 例如&#xff0c;给出 前序遍历 preorder [3,9,20,15,7] 中序遍历 inorder [9,3,15,20,7] 返回如下的二叉树&#xff1a; class Solution { public:Tr…

使用WPS自动化转换办公文档: 将Word, PowerPoint和Excel文件转换为PDF

&#x1f337;&#x1f341; 博主猫头虎 带您 Go to New World.✨&#x1f341; &#x1f984; 博客首页——猫头虎的博客&#x1f390; &#x1f433;《面试题大全专栏》 文章图文并茂&#x1f995;生动形象&#x1f996;简单易学&#xff01;欢迎大家来踩踩~&#x1f33a; &a…

“把握拐点,洞悉投资者情绪与比特币价格的未来之路!“

“本来这篇文章是昨天晚上发的&#xff0c;国庆节庆祝喝多了&#xff0c;心有余而力不足&#xff01;直接头躺马桶GG了” 标准普尔 500 指数 200 天移动平均线云是我几个月来一直分享的下行目标&#xff0c;上周正式重新测试了该目标。200 日移动平均线云表示为: 200 天指数移…

国庆day4

运算符重载代码 #include <iostream> using namespace std; class Num { private:int num1; //实部int num2; //虚部 public:Num(){}; //无参构造Num(int n1,int n2):num1(n1),num2(n2){}; //有参构造~Num(){}; //析构函数const Num operator(const Num &other)cons…

北大硕士7年嵌入式学习经验分享

阶段 1 大一到大三这个阶段我与大多数学生相同&#xff1a; 学习本专业知识&#xff08;EE专业&#xff09;&#xff0c;学习嵌入式软件开发需要的计算机课程&#xff08;汇编原理&#xff0c;计算机组成原理&#xff0c;操作系统&#xff0c;C语言等&#xff09;&#xff0c…

oracle GBK未定义编码使用Unicode写入特殊字符e000迁移lightdb-x测试

E:\HS\LightDBSVN\23.3sql文件\迁移工具\caofa\config\application.properties gbk-->uft8: logging.configclasspath:log4j2.xml # ???? etl.global.sourceDatabaseoracle etl.global.targetDatabaselightdb etl.global.showSqlfalse etl.global.fastFailfalse etl.g…

【智能家居项目】裸机版本——设备子系统(LED Display 风扇)

&#x1f431;作者&#xff1a;一只大喵咪1201 &#x1f431;专栏&#xff1a;《智能家居项目》 &#x1f525;格言&#xff1a;你只管努力&#xff0c;剩下的交给时间&#xff01; 输入子系统中目前仅实现了按键输入&#xff0c;剩下的网络输入和标准输入在以后会逐步实现&am…