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
英文地址,請注明出處:http://en.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 …