C#程序员计算器

在这里插入图片描述
使用C#语言编写程序员计算器,使其能够进行加减乘除和与或非等逻辑运算。
calculator.cs 代码如下

using System;
using System.Numerics;
using System.Globalization;namespace Calculator1
{public enum CalcBase { Bin = 2, Oct = 8, Dec = 10, Hex = 16 }public enum BitWidth { Bit8 = 8, Bit16 = 16, Bit32 = 32, Bit64 = 64 }public class Calculator{public CalcBase CurrentBase { get; private set; } = CalcBase.Dec;public BitWidth CurrentBitWidth { get; private set; } = BitWidth.Bit64;public string CurrentInput { get; private set; } = "0";public string LastResult { get; private set; } = "0";public string Operand1Display { get; private set; } = "";public string Operand2Display { get; private set; } = "";public string OperatorDisplay { get; private set; } = "";// 新增:四行显示属性public string OperationDisplay { get; private set; } = "";  // 运算符 + 第二个操作数public string ResultDisplay { get; private set; } = "";     // 等号 + 结果public string CurrentInputDisplay { get; private set; } = "0"; // 当前输入显示// 新增:不同进制的显示值public string BinaryDisplay { get; private set; } = "0";public string OctalDisplay { get; private set; } = "0";public string DecimalDisplay { get; private set; } = "0";public string HexadecimalDisplay { get; private set; } = "0";private BigInteger? operand = null;private string? lastOperator = null;private bool isNewInput = true;private string lastInputBeforeOp = "0";// 新增:保存最后的运算信息用于显示private string? lastOperationForDisplay = null;private string? lastResultForDisplay = null;public void SetBase(CalcBase calcBase){CurrentBase = calcBase;// 切换进制时,当前输入和结果都要转换CurrentInput = ConvertBase(CurrentInput, CurrentBase);LastResult = ConvertBase(LastResult, CurrentBase);if (operand != null)Operand1Display = ToBaseString(operand.Value, CurrentBase);elseOperand1Display = "";Operand2Display = CurrentInput;CurrentInputDisplay = CurrentInput;UpdateOperationDisplay();UpdateResultDisplay();UpdateBaseDisplays();}public void SetBitWidth(BitWidth bitWidth){CurrentBitWidth = bitWidth;// 位宽切换时自动溢出处理LastResult = ApplyBitWidth(LastResult);CurrentInput = LastResult;if (operand != null)Operand1Display = ToBaseString(operand.Value, CurrentBase);elseOperand1Display = "";Operand2Display = CurrentInput;CurrentInputDisplay = CurrentInput;UpdateOperationDisplay();UpdateResultDisplay();UpdateBaseDisplays();}public void Input(string value){if (isNewInput){CurrentInput = value;isNewInput = false;}else{if (CurrentInput == "0")CurrentInput = value;elseCurrentInput += value;}Operand2Display = CurrentInput;CurrentInputDisplay = CurrentInput;UpdateOperationDisplay();UpdateBaseDisplays();}public void Clear(){CurrentInput = "0";operand = null;lastOperator = null;LastResult = "0";Operand1Display = "";Operand2Display = "";OperatorDisplay = "";OperationDisplay = "";ResultDisplay = "";CurrentInputDisplay = "0";lastOperationForDisplay = null;lastResultForDisplay = null;isNewInput = true;UpdateBaseDisplays();}public void ClearEntry(){CurrentInput = "0";Operand2Display = "0";CurrentInputDisplay = "0";UpdateOperationDisplay();isNewInput = true;UpdateBaseDisplays();}public void SetOperator(string op){if (operand == null){operand = ParseInput(CurrentInput, CurrentBase);Operand1Display = ToBaseString(operand.Value, CurrentBase);// 开始新运算时清除之前的显示信息lastOperationForDisplay = null;lastResultForDisplay = null;}else if (!isNewInput){Calculate();operand = ParseInput(LastResult, CurrentBase);Operand1Display = ToBaseString(operand.Value, CurrentBase);// 开始新运算时清除之前的显示信息lastOperationForDisplay = null;lastResultForDisplay = null;}lastOperator = op;OperatorDisplay = op;lastInputBeforeOp = CurrentInput;isNewInput = true;UpdateOperationDisplay();UpdateResultDisplay();}public void Calculate(){if (operand == null || lastOperator == null) return;var right = ParseInput(CurrentInput, CurrentBase);BigInteger result = operand.Value;switch (lastOperator){case "+": result += right; break;case "-": result -= right; break;case "*": result *= right; break;case "/": result = right == 0 ? 0 : result / right; break;case "%": result = right == 0 ? 0 : result % right; break;case "AND": result &= right; break;case "OR": result |= right; break;case "XOR": result ^= right; break;case "|": result |= right; break;case "^": result ^= right; break;case "<<": result = result << (int)right; break;case ">>": result = result >> (int)right; break;}result = ApplyBitWidth(result);LastResult = ToBaseString(result, CurrentBase);CurrentInput = LastResult;Operand2Display = CurrentInput;CurrentInputDisplay = CurrentInput;// 保存运算信息用于显示lastOperationForDisplay = $"{lastOperator} {ToBaseString(right, CurrentBase)}";lastResultForDisplay = $"= {LastResult}";operand = null;lastOperator = null;OperatorDisplay = "";isNewInput = true;UpdateOperationDisplay();UpdateResultDisplay();UpdateBaseDisplays();}public void Not(){var value = ParseInput(CurrentInput, CurrentBase);value = ~value;value = ApplyBitWidth(value);LastResult = ToBaseString(value, CurrentBase);CurrentInput = LastResult;Operand2Display = CurrentInput;CurrentInputDisplay = CurrentInput;isNewInput = true;UpdateOperationDisplay();UpdateResultDisplay();UpdateBaseDisplays();}public void Negate(){var value = ParseInput(CurrentInput, CurrentBase);value = -value;value = ApplyBitWidth(value);LastResult = ToBaseString(value, CurrentBase);CurrentInput = LastResult;Operand2Display = CurrentInput;CurrentInputDisplay = CurrentInput;isNewInput = true;UpdateOperationDisplay();UpdateResultDisplay();UpdateBaseDisplays();}public string ConvertBase(string value, CalcBase toBase){var num = ParseInput(value, CurrentBase);return ToBaseString(num, toBase);}// 新增:更新不同进制的显示值private void UpdateBaseDisplays(){try{var num = ParseInput(CurrentInput, CurrentBase);BinaryDisplay = ToBaseString(num, CalcBase.Bin);OctalDisplay = ToBaseString(num, CalcBase.Oct);DecimalDisplay = ToBaseString(num, CalcBase.Dec);HexadecimalDisplay = ToBaseString(num, CalcBase.Hex);}catch{BinaryDisplay = "0";OctalDisplay = "0";DecimalDisplay = "0";HexadecimalDisplay = "0";}}// 新增:更新运算显示private void UpdateOperationDisplay(){if (string.IsNullOrEmpty(lastOperator)){// 如果没有当前运算符,但有保存的运算信息,则显示保存的信息OperationDisplay = lastOperationForDisplay ?? "";}else{OperationDisplay = $"{lastOperator} {CurrentInput}";}}// 新增:更新结果显示private void UpdateResultDisplay(){if (operand == null || string.IsNullOrEmpty(lastOperator)){// 如果没有当前运算,但有保存的结果信息,则显示保存的信息ResultDisplay = lastResultForDisplay ?? "";}else if (isNewInput && operand != null){// 计算完成后显示结果ResultDisplay = $"= {LastResult}";}else{ResultDisplay = "";}}private BigInteger ParseInput(string value, CalcBase fromBase){if (string.IsNullOrEmpty(value)) return 0;value = value.Trim();try{return fromBase switch{CalcBase.Bin => Convert.ToInt64(value, 2),CalcBase.Oct => Convert.ToInt64(value, 8),CalcBase.Dec => BigInteger.Parse(value),CalcBase.Hex => BigInteger.Parse(value, System.Globalization.NumberStyles.AllowHexSpecifier),_ => BigInteger.Parse(value)};}catch{return 0;}}private string ToBaseString(BigInteger value, CalcBase toBase){// 处理负数补码显示if (value < 0 && (toBase == CalcBase.Bin || toBase == CalcBase.Oct || toBase == CalcBase.Hex)){int bits = (int)CurrentBitWidth;BigInteger mask = (BigInteger.One << bits) - 1;value &= mask;}return toBase switch{CalcBase.Bin => Convert.ToString((long)value, 2),CalcBase.Oct => Convert.ToString((long)value, 8),CalcBase.Dec => value.ToString(),CalcBase.Hex => value.ToString("X"),_ => value.ToString()};}private string ApplyBitWidth(string value){var num = ParseInput(value, CurrentBase);return ToBaseString(ApplyBitWidth(num), CurrentBase);}private BigInteger ApplyBitWidth(BigInteger value){int bits = (int)CurrentBitWidth;BigInteger mask = (BigInteger.One << bits) - 1;value &= mask;// 处理有符号数(最高位为1时为负数)if ((value & (BigInteger.One << (bits - 1))) != 0){value -= (BigInteger.One << bits);}return value;}}
} 

From1.Designer.cs 代码如下:

namespace Calculator1
{partial class Form1{/// <summary>///  Required designer variable./// </summary>private System.ComponentModel.IContainer components = null;/// <summary>///  Clean up any resources being used./// </summary>/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>protected override void Dispose(bool disposing){if (disposing && (components != null)){components.Dispose();}base.Dispose(disposing);}#region Windows Form Designer generated code/// <summary>///  Required method for Designer support - do not modify///  the contents of this method with the code editor./// </summary>private void InitializeComponent(){txtDisplay = new TextBox();grpBase = new GroupBox();rdoBin = new RadioButton();rdoOct = new RadioButton();rdoDec = new RadioButton();rdoHex = new RadioButton();grpBits = new GroupBox();rdo8 = new RadioButton();rdo16 = new RadioButton();rdo32 = new RadioButton();rdo64 = new RadioButton();tblButtons = new TableLayoutPanel();lblOperand1 = new Label();lblOperand2 = new Label();lblResult = new Label();lblOperation = new Label();lblCurrentInput = new Label();lblBinaryDisplay = new Label();lblOctalDisplay = new Label();lblDecimalDisplay = new Label();lblHexadecimalDisplay = new Label();grpBase.SuspendLayout();grpBits.SuspendLayout();SuspendLayout();// // txtDisplay// txtDisplay.BackColor = Color.WhiteSmoke;txtDisplay.Font = new Font("Segoe UI", 24F, FontStyle.Bold);txtDisplay.Location = new Point(35, 55);txtDisplay.Margin = new Padding(5);txtDisplay.Name = "txtDisplay";txtDisplay.ReadOnly = true;txtDisplay.Size = new Size(977, 93);txtDisplay.TabIndex = 0;txtDisplay.TextAlign = HorizontalAlignment.Right;txtDisplay.Visible = false;// // grpBase// grpBase.Controls.Add(rdoBin);grpBase.Controls.Add(rdoOct);grpBase.Controls.Add(rdoDec);grpBase.Controls.Add(rdoHex);grpBase.Location = new Point(1050, 77);grpBase.Margin = new Padding(5);grpBase.Name = "grpBase";grpBase.Padding = new Padding(5);grpBase.Size = new Size(210, 279);grpBase.TabIndex = 1;grpBase.TabStop = false;grpBase.Text = "进制";// // rdoBin// rdoBin.AutoSize = true;rdoBin.Location = new Point(35, 46);rdoBin.Margin = new Padding(5);rdoBin.Name = "rdoBin";rdoBin.Size = new Size(81, 35);rdoBin.TabIndex = 0;rdoBin.TabStop = true;rdoBin.Text = "Bin";rdoBin.UseVisualStyleBackColor = true;// // rdoOct// rdoOct.AutoSize = true;rdoOct.Location = new Point(35, 101);rdoOct.Margin = new Padding(5);rdoOct.Name = "rdoOct";rdoOct.Size = new Size(86, 35);rdoOct.TabIndex = 1;rdoOct.TabStop = true;rdoOct.Text = "Oct";rdoOct.UseVisualStyleBackColor = true;// // rdoDec// rdoDec.AutoSize = true;rdoDec.Location = new Point(35, 155);rdoDec.Margin = new Padding(5);rdoDec.Name = "rdoDec";rdoDec.Size = new Size(89, 35);rdoDec.TabIndex = 2;rdoDec.TabStop = true;rdoDec.Text = "Dec";rdoDec.UseVisualStyleBackColor = true;// // rdoHex// rdoHex.AutoSize = true;rdoHex.Location = new Point(35, 209);rdoHex.Margin = new Padding(5);rdoHex.Name = "rdoHex";rdoHex.Size = new Size(90, 35);rdoHex.TabIndex = 3;rdoHex.TabStop = true;rdoHex.Text = "Hex";rdoHex.UseVisualStyleBackColor = true;// // grpBits// grpBits.Controls.Add(rdo8);grpBits.Controls.Add(rdo16);grpBits.Controls.Add(rdo32);grpBits.Controls.Add(rdo64);grpBits.Location = new Point(1050, 594);grpBits.Margin = new Padding(5);grpBits.Name = "grpBits";grpBits.Padding = new Padding(5);grpBits.Size = new Size(210, 279);grpBits.TabIndex = 2;grpBits.TabStop = false;grpBits.Text = "位宽";// // rdo8// rdo8.AutoSize = true;rdo8.Location = new Point(35, 46);rdo8.Margin = new Padding(5);rdo8.Name = "rdo8";rdo8.Size = new Size(83, 35);rdo8.TabIndex = 0;rdo8.TabStop = true;rdo8.Text = "8位";rdo8.UseVisualStyleBackColor = true;// // rdo16// rdo16.AutoSize = true;rdo16.Location = new Point(35, 101);rdo16.Margin = new Padding(5);rdo16.Name = "rdo16";rdo16.Size = new Size(97, 35);rdo16.TabIndex = 1;rdo16.TabStop = true;rdo16.Text = "16位";rdo16.UseVisualStyleBackColor = true;// // rdo32// rdo32.AutoSize = true;rdo32.Location = new Point(35, 155);rdo32.Margin = new Padding(5);rdo32.Name = "rdo32";rdo32.Size = new Size(97, 35);rdo32.TabIndex = 2;rdo32.TabStop = true;rdo32.Text = "32位";rdo32.UseVisualStyleBackColor = true;// // rdo64// rdo64.AutoSize = true;rdo64.Location = new Point(35, 209);rdo64.Margin = new Padding(5);rdo64.Name = "rdo64";rdo64.Size = new Size(97, 35);rdo64.TabIndex = 3;rdo64.TabStop = true;rdo64.Text = "64位";rdo64.UseVisualStyleBackColor = true;// // tblButtons// tblButtons.BackColor = Color.White;tblButtons.ColumnCount = 6;tblButtons.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 20F));tblButtons.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 20F));tblButtons.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 20F));tblButtons.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 20F));tblButtons.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 20F));tblButtons.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 20F));tblButtons.Location = new Point(35, 400);tblButtons.Margin = new Padding(5);tblButtons.Name = "tblButtons";tblButtons.RowCount = 6;tblButtons.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));tblButtons.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));tblButtons.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));tblButtons.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));tblButtons.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));tblButtons.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));tblButtons.Size = new Size(980, 480);tblButtons.TabIndex = 3;// // lblOperand1// lblOperand1.Font = new Font("Segoe UI", 24F, FontStyle.Bold);lblOperand1.ForeColor = Color.Gray;lblOperand1.Location = new Point(35, 16);lblOperand1.Margin = new Padding(5, 0, 5, 0);lblOperand1.Name = "lblOperand1";lblOperand1.Size = new Size(980, 80);lblOperand1.TabIndex = 2;lblOperand1.TextAlign = ContentAlignment.MiddleRight;// // lblOperand2// lblOperand2.Location = new Point(0, 0);lblOperand2.Name = "lblOperand2";lblOperand2.Size = new Size(100, 23);lblOperand2.TabIndex = 0;// // lblResult// lblResult.Font = new Font("Segoe UI", 24F, FontStyle.Bold);lblResult.ForeColor = Color.Black;lblResult.Location = new Point(35, 204);lblResult.Margin = new Padding(5, 0, 5, 0);lblResult.Name = "lblResult";lblResult.Size = new Size(980, 80);lblResult.TabIndex = 0;lblResult.TextAlign = ContentAlignment.MiddleRight;// // lblOperation// lblOperation.Font = new Font("Segoe UI", 24F, FontStyle.Bold);lblOperation.ForeColor = Color.DimGray;lblOperation.Location = new Point(35, 110);lblOperation.Margin = new Padding(5, 0, 5, 0);lblOperation.Name = "lblOperation";lblOperation.Size = new Size(980, 80);lblOperation.TabIndex = 3;lblOperation.TextAlign = ContentAlignment.MiddleRight;// // lblCurrentInput// lblCurrentInput.Font = new Font("Segoe UI", 24F, FontStyle.Bold);lblCurrentInput.ForeColor = Color.Blue;lblCurrentInput.Location = new Point(35, 298);lblCurrentInput.Margin = new Padding(5, 0, 5, 0);lblCurrentInput.Name = "lblCurrentInput";lblCurrentInput.Size = new Size(980, 80);lblCurrentInput.TabIndex = 1;lblCurrentInput.TextAlign = ContentAlignment.MiddleRight;// // lblBinaryDisplay// lblBinaryDisplay.Font = new Font("Segoe UI", 12F, FontStyle.Bold);lblBinaryDisplay.ForeColor = Color.DarkGreen;lblBinaryDisplay.Location = new Point(1050, 380);lblBinaryDisplay.Margin = new Padding(5, 0, 5, 0);lblBinaryDisplay.Name = "lblBinaryDisplay";lblBinaryDisplay.Size = new Size(210, 40);lblBinaryDisplay.TabIndex = 4;lblBinaryDisplay.Text = "Bin: 0";lblBinaryDisplay.TextAlign = ContentAlignment.MiddleLeft;lblBinaryDisplay.Click += lblBinaryDisplay_Click;// // lblOctalDisplay// lblOctalDisplay.Font = new Font("Segoe UI", 12F, FontStyle.Bold);lblOctalDisplay.ForeColor = Color.DarkBlue;lblOctalDisplay.Location = new Point(1050, 430);lblOctalDisplay.Margin = new Padding(5, 0, 5, 0);lblOctalDisplay.Name = "lblOctalDisplay";lblOctalDisplay.Size = new Size(210, 40);lblOctalDisplay.TabIndex = 5;lblOctalDisplay.Text = "Oct: 0";lblOctalDisplay.TextAlign = ContentAlignment.MiddleLeft;// // lblDecimalDisplay// lblDecimalDisplay.Font = new Font("Segoe UI", 12F, FontStyle.Bold);lblDecimalDisplay.ForeColor = Color.DarkRed;lblDecimalDisplay.Location = new Point(1050, 480);lblDecimalDisplay.Margin = new Padding(5, 0, 5, 0);lblDecimalDisplay.Name = "lblDecimalDisplay";lblDecimalDisplay.Size = new Size(210, 40);lblDecimalDisplay.TabIndex = 6;lblDecimalDisplay.Text = "Dec: 0";lblDecimalDisplay.TextAlign = ContentAlignment.MiddleLeft;// // lblHexadecimalDisplay// lblHexadecimalDisplay.Font = new Font("Segoe UI", 12F, FontStyle.Bold);lblHexadecimalDisplay.ForeColor = Color.DarkOrange;lblHexadecimalDisplay.Location = new Point(1050, 530);lblHexadecimalDisplay.Margin = new Padding(5, 0, 5, 0);lblHexadecimalDisplay.Name = "lblHexadecimalDisplay";lblHexadecimalDisplay.Size = new Size(210, 40);lblHexadecimalDisplay.TabIndex = 7;lblHexadecimalDisplay.Text = "Hex: 0";lblHexadecimalDisplay.TextAlign = ContentAlignment.MiddleLeft;// // Form1// AutoScaleDimensions = new SizeF(14F, 31F);AutoScaleMode = AutoScaleMode.Font;ClientSize = new Size(1330, 908);Controls.Add(lblResult);Controls.Add(lblOperation);Controls.Add(lblCurrentInput);Controls.Add(lblOperand1);Controls.Add(txtDisplay);Controls.Add(grpBase);Controls.Add(grpBits);Controls.Add(tblButtons);Controls.Add(lblBinaryDisplay);Controls.Add(lblOctalDisplay);Controls.Add(lblDecimalDisplay);Controls.Add(lblHexadecimalDisplay);FormBorderStyle = FormBorderStyle.FixedSingle;Margin = new Padding(5);MaximizeBox = false;Name = "Form1";StartPosition = FormStartPosition.CenterScreen;Text = "程序员计算器";grpBase.ResumeLayout(false);grpBase.PerformLayout();grpBits.ResumeLayout(false);grpBits.PerformLayout();ResumeLayout(false);PerformLayout();}#endregionprivate System.Windows.Forms.TextBox txtDisplay;private System.Windows.Forms.GroupBox grpBase;private System.Windows.Forms.RadioButton rdoBin;private System.Windows.Forms.RadioButton rdoOct;private System.Windows.Forms.RadioButton rdoDec;private System.Windows.Forms.RadioButton rdoHex;private System.Windows.Forms.GroupBox grpBits;private System.Windows.Forms.RadioButton rdo8;private System.Windows.Forms.RadioButton rdo16;private System.Windows.Forms.RadioButton rdo32;private System.Windows.Forms.RadioButton rdo64;private System.Windows.Forms.TableLayoutPanel tblButtons;private System.Windows.Forms.Label lblOperand1;private System.Windows.Forms.Label lblOperand2;private System.Windows.Forms.Label lblResult;private System.Windows.Forms.Label lblOperation;private System.Windows.Forms.Label lblCurrentInput;private System.Windows.Forms.Label lblBinaryDisplay;private System.Windows.Forms.Label lblOctalDisplay;private System.Windows.Forms.Label lblDecimalDisplay;private System.Windows.Forms.Label lblHexadecimalDisplay;}
}

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

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

相关文章

国产音频DA转换芯片DP7361支持192K六通道24位DA转换器

产品概述 DP7361 是一款立体声六通道线性输出的数模转换器&#xff0c;内含插值滤波器、Multi-Bit 数模转换 器、模拟输出滤波器&#xff0c;支持主流的音频数据格式。 DP7361 片上集成线性低通模拟滤波器和四阶 Multi-Bit Δ-∑调制器&#xff0c;能自动检测信号频率和主时钟频…

【C51单片机四个按键控制流水灯】2022-9-30

缘由C51&#xff0c;四个按键控制流水灯-嵌入式-CSDN问答 #include "REG52.h" sbit k1P3^0; sbit k2P3^1; sbit k3P3^2; sbit k4P3^3; unsigned char code lsd[]{127,191,223,239,247,251,253,254};//跑马灯 void jsys(unsigned char y,unsigned char s){unsigned c…

Python 脚本:获取公网 IPv4 和 IPv6 地址

本方案适合拨号宽带网络环境&#xff0c;当检测到公网IP地址变更时&#xff0c;可联动自动触发MQTT消息推送或邮件通知&#xff0c;实现动态IP的实时监控与告警。 0x01 代码import re import time import requestsdef extract_ip(html):"""用正则提取 IP&…

数字化转型-制造业未来蓝图:“超自动化”工厂

超自动化&#xff1a;2040年未来工厂的颠覆性蓝图工业革命250年后的新一轮范式革命 &#xff08;埃森哲&#xff1a;未来的制造&#xff1a;超自动化工厂蓝图有感&#xff09;&#x1f504; 从机械化到超自动化&#xff1a;制造业的第五次进化 自18世纪工业革命始&#xff0c;…

Java 15 新特性解析与代码示例

Java 15 新特性解析与代码示例 文章目录Java 15 新特性解析与代码示例引言1. 密封类&#xff08;Sealed Classes&#xff09;1.1. 什么是密封类&#xff1f;1.2. 为什么使用密封类&#xff1f;1.3. 语法1.4. 与传统方法的对比1.5. 使用场景1.6. 示例&#xff1a;结合模式匹配2.…

Vue 3 入门教程 - 1、基础概念与环境搭建

一、Vue 3 简介 Vue.js 是一款流行的 JavaScript 前端框架&#xff0c;用于构建用户界面。Vue 3 作为其最新版本&#xff0c;带来了诸多令人瞩目的新特性与性能优化&#xff0c;为开发者打造了更为高效、灵活的开发体验。 1.1 Vue 3 的优势 性能提升&#xff1a;对虚拟 DOM …

SpringBoot之多环境配置全解析

SpringBoot之多环境配置全解析一、多环境配置的核心思路二、3种配置文件格式详解2.1 properties格式&#xff08;传统格式&#xff09;1. 基础配置文件&#xff08;application.properties&#xff09;2. 环境专属配置文件2.2 yaml/yml格式&#xff08;推荐&#xff09;1. 单文…

uvm-tlm-nonblocking-get-port

前文展示了使用本质为阻塞性质的uvm_blocking_get_port TLM端口的示例&#xff0c;其中接收方会停滞等待发送方完成get任务。类似地&#xff0c;UVM TLM还提供非阻塞类型的uvm_nonblocking_get_port&#xff0c;发送方需通过try_get来检测get是否成功&#xff0c;或通过can_get…

【NCS随笔】如何在hello_world添加蓝牙功能(一)

如何在hello_world添加蓝牙功能&#xff08;一&#xff09;环境准备 硬件&#xff1a;nRF54L15DK 软件版本&#xff1a;NCS3.0.2 例程&#xff1a;hello_world 宏的配置 # Config loggerCONFIG_LOGyCONFIG_USE_SEGGER_RTTyCONFIG_LOG_BACKEND_RTTyCONFIG_LOG_BACKEND_UARTnONFI…

机器学习——KNN实现手写数字识别:基于 OpenCV 和 scikit-learn 的实战教学 (超级超级超级简单)

用KNN实现手写数字识别&#xff1a;基于 OpenCV 和 scikit-learn 的实战教学在这篇文章中&#xff0c;我们将使用 KNN&#xff08;K-Nearest Neighbors&#xff09;算法对手写数字进行分类识别。我们会用 OpenCV 读取图像并预处理数据&#xff0c;用 scikit-learn 构建并训练模…

【Git】分支

文章目录理解分支创建分支切换分支合并分支删除分支合并冲突分支管理策略分支策略bug 分支删除临时分支小结理解分支 本章开始介绍 Git 的杀手级功能之一&#xff08;注意是之一&#xff0c;也就是后面还有之二&#xff0c;之三……&#xff09;&#xff1a;分支。分支就是科幻…

【32】C# WinForm入门到精通 ——打开文件OpenFileDialog 【属性、方法、事件、实例、源码】

WinForm 是 Windows Form 的简称&#xff0c;是基于 .NET Framework 平台的客户端&#xff08;PC软件&#xff09;开发技术&#xff0c;是 C# 语言中的一个重要应用。 .NET 提供了大量 Windows 风格的控件和事件&#xff0c;可以直接拿来使用。 本专栏内容是按照标题序号逐渐…

Wan2.2开源第1天:动态灯光功能开启创意氛围新境界

在开源软件蓬勃发展的今天&#xff0c;每一次新版本的发布都如同在创意的星空中点亮了一颗璀璨的新星。今天&#xff0c;&#xff08;通义万相国际版wan&#xff09;Wan2.2正式开源&#xff0c;它带着令人眼前一亮的动态灯光功能惊艳登场&#xff0c;为所有追求创意与氛围营造的…

Excel制作滑珠图、哑铃图

Excel制作滑珠图、哑铃图效果展示在较长时间周期内&#xff0c;很多参数都是在一定范围内浮动的&#xff0c;并不是一成不变的&#xff0c;为了直观表达各类别的浮动范围&#xff0c;使用“滑珠图”就是一个不错的选择&#xff0c;当滑珠图两侧均有珠子的时候&#xff0c;又称为…

Day07 JDBC+MyBatis

1.JDBC入门程序2.JDBC执行DQL语句3.JDBC预编译SQL 防止SQL注入随便输入用户名&#xff0c;密码为or1 1,sql注入4.Mybatis入门 Mapper 持久层XxxMapper替代Dao4.1调用接口的findAll()方法时自动执行上方的SQL语句&#xff0c;并将SQL查询的语句自动封装到返回值中5.Mybatis辅助…

OSS-服务端签名Web端直传+STS获取临时凭证+POST签名v4版本开发过程中的细节

这里写自定义目录标题配置OSS服务端代码初始化STS Client获取STS临时凭证创建policy计算SigningKeyOSSUtil.javaSTSPolicyDTO.java提供接口Apifox模拟Web端文件直传本文主要结合服务端STS获取临时凭证(签名)直传官方文档对开发中比较容易出错的地方加以提醒&#xff1b;建议主要…

uniapp实现微信小程序导航功能

1.导航按钮<button click"navigation()">导航到仓库</button>2.导航功能const navigation (item) > {let address item.province item.city item.district item.address //地址let latitude Number(item.latitude) …

07.4-使用 use 关键字引入路径

使用 use 关键字引入路径 每次调用函数时都必须写出完整路径&#xff0c;可能会感觉不便且重复。在清单7-7中&#xff0c;无论我们选择绝对路径还是相对路径来调用 add_to_waitlist 函数&#xff0c;每次调用时都必须指定 front_of_house 和 hosting。幸运的是&#xff0c;有一…

7.Linux :进程管理,进程控制与计划任务

Linux &#xff1a;进程管理&#xff0c;进程控制与计划任务 一、进程管理 1. 进程与程序 程序&#xff1a;静态的可执行文件&#xff08;存储于磁盘&#xff09;。进程&#xff1a;动态执行的程序实例&#xff08;占用CPU/内存&#xff09;。 2. 查看进程命令作用常用组合ps静…

Matplotlib(四)- 图表样式美化

文章目录一、Matplotlib图表样式介绍1. 图表样式简介2. 默认图表样式2.1 查看默认配置2.2 常用的配置3. 图表样式修改3.1 局部修改3.1.1 通过绘图方法设置参数修改3.1.2 通过rcParams修改3.1.3 通过rc()方法修改3.2 全局修改二、颜色设置1. 颜色的三种表示方式1.1 颜色单词1.2 …