admin 管理员组

文章数量: 887021


2024年1月23日发(作者:ventimono官网)

哈哈哈20道编程代码1.1000以内的全部完数Private Sub Command1_Click() Dim n As Integer Dim i As Integer Dim s As Long For n = 1 To 1000 s = 1 For i = 2 To n - 1 If n Mod i = 0 Then s = s + i Next i If s = n Then Text1 = Text1 & n & " "

If k Mod 5 = 0 Then Text1 = Text1 & vbCrLf End If Next nEnd SubPrivate Sub Command2_Click() EndEnd Sub2.百元买百鸡Private Sub Command1_Click()Dim i As IntegerDim j As IntegerFor i = 0 To 20 For j = 0 To 33 If 5 * i + 3 * j + (100 - i - j) * 1 / 3 = 100 Then Text1 = Text1 & "买" & CStr(i) & "只公鸡" & CStr(j) & "只母鸡" & CStr(100 - i

- j) & "只小鸡" Text1 = Text1 & Chr(13) & Chr(10) End If Next j

Next iEnd SubPrivate Sub Command2_Click() EndEnd Sub3.不靠边元素和Private Sub Command1_Click()ClsRandomizeDim a(5, 5) As Integer, s%For i = 0 To 5 For j = 0 To 5 a(i, j) = Int(Rnd * 9) Print a(i, j) & ","; Sum = Sum + a(i, j) Next j PrintNext ik = SumSum = 0For i = 0 To 5Sum = Sum + a(i, 0) + a(i, 5) + a(0, i) + a(5, i)Next iSum = Sum - a(0, 0) - a(5, 0) - a(5, 5) - a(0, 5)Text1 = k - SumEnd SubPrivate Sub Command2_Click() EndEnd Sub4.递归函数求斐波拉契数列Option ExplicitPrivate Sub Command1_Click() Dim a1, a2, b As Integer Dim i, n As Integer n = InputBox("显示数列的前N项") a1 = 1 For i = 1 To n

b = a1 + a2 t = b & " " a1 = a2 a2 = b Next iEnd SubPrivate Sub Command2_Click() EndEnd Sub5.各位数之和Private Sub Command1_Click() Dim i As String Dim j% Dim s% i = Text1 For j = 1 To Len(i) st = Mid(i, j, 1) s = s + Val(st) Next j Text2 = sEnd SubPrivate Sub Command2_Click() EndEnd Sub6.回文数Private Sub Command1_Click() Dim x$, y$, c$, i% x = Text1 For i = 1 To Len(x) c = Mid(x, i, 1) y = c + y Next i If y = x Then Text2 = "x是回文数" Else Text2 = "x不是回文数" End IfEnd Sub


本文标签: 代码 官网 靠边 作者 元素