水仙花数(方法二).frm

来自「算法教案」· FRM 代码 · 共 59 行

FRM
59
字号
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "水仙花数"
   ClientHeight    =   4710
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   5880
   LinkTopic       =   "Form1"
   ScaleHeight     =   4710
   ScaleWidth      =   5880
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "计算"
      Height          =   495
      Left            =   4080
      TabIndex        =   1
      Top             =   2760
      Width           =   975
   End
   Begin VB.ListBox List1 
      Height          =   3660
      ItemData        =   "水仙花数(方法二).frx":0000
      Left            =   240
      List            =   "水仙花数(方法二).frx":0002
      TabIndex        =   0
      Top             =   480
      Width           =   3375
   End
   Begin VB.Label Label1 
      Height          =   735
      Left            =   3840
      TabIndex        =   2
      Top             =   840
      Width           =   1815
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
    Dim sum As Integer
    Dim i, j, k As Integer
    List1.Clear
    For i = 1 To 9
        For j = 0 To 9
            For k = 0 To 9
                If i ^ 3 + j ^ 3 + k ^ 3 = 100 * i + 10 * j + k Then
                    List1.AddItem (Str(100 * i + 10 * j + k))
                    sum = sum + 1
                End If
            Next k
        Next j
    Next i
    Label1.Caption = "个数:" + Str(sum)
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?