[ VB2010 ] --用遞迴方法 輸入一個整數n,並用遞迴求解1+2+3…n之和.
Public Class Form1
Private Function sum(ByVal n As Integer) '/*遞迴程式部分*/
If n = 1 Then
Return 1
Else
Return sum(n - 1) + n
End If
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim n As Integer
n = Val(TextBox2.Text)
TextBox3.Text = sum(n).ToString()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
訂閱:
張貼留言 (Atom)
WOKWI 超音波測距模組 HC-SR04 透過MQTT給 EasyBulider Tank 顯示液體高度
WOKWI 超音波測距模組 HC-SR04 透過MQTT給 EasyBulider Tank 顯示液體高度 這段 Arduino C++ 程式碼適用於 ESP32 開發板,主要功能為:透過 NewPing 超音波感測器 測量液位/距離、將數據顯示於 I2C 1602 L...
-
數位IC設計入門-Verilog combinational logic 8 to 1 Multiplexer 多工器 Behavioral Modeling (& Test Bench) //數位IC設計入門-Verilog combinationa...
-
Line 發報機 Python TKinter (CONFIG_LINE Message API_2.py) import serial import serial.tools.list_ports import tkinter as tk from tkinter import...
-
python pip 不是内部或外部命令 -- 解決方法 要安裝 Pyqt5 1. 首先,開啟命令提示字元。 2. 輸入 pip3 install pyqt5 好像不能執行 ! ! 錯誤顯示 : ‘ pip3 ’ 不是內部或外部命令、可執行的程式或批...

沒有留言:
張貼留言