bài tập CLC Nhập 5 số nguyên dương

2 386 0
bài tập CLC Nhập 5 số nguyên dương

Đang tải... (xem toàn văn)

Thông tin tài liệu

Nhập 5 số nguyên dương. Tính các đại lượng như trên form Dim a(5) As Integer Dim dem As Integer Dim i As Integer Dim us As Integer Dim bs As Integer Dim maxgt As Double Dim min As Integer Dim max As Integer Private Function nto(x As Integer) As Boolean dem = 0 For i = 1 To x If x Mod i = 0 Then dem = dem + 1 Next i If dem = 2 Then nto = True Else nto = False End If End Function Private Sub Command2_Click() txtA.Text = "" For i = 0 To 4 txtA.Text = txtA.Text & Str(a(i)) & " " Next i End Sub Private Sub Command3_Click() Dim i As Integer Dim n n = 5 txtchia2.Text = "" max = a(0) min = a(0) MsgBox Str(min) & " " & Str(max) For i = 0 To n - 1 If a(i) > 0 And Int(a(i)) = a(i) And a(i) Mod 2 = 0 Then txtchia2.Text = txtchia2.Text & Str(a(i)) & " " End If If max < a(i) Then max = a(i) If min > a(i) Then min = a(i) MsgBox Str(min) & " " & Str(max) Next i txtmax.Text = Str(max) txtmin.Text = Str(min) txtnt.Text = "" For i = min To max If nto(i) = True Then txtnt.Text = txtnt.Text & Str(i) & " " End If Next i maxgt = 1 For i = 1 To max maxgt = maxgt * i Next i us = min Do While min Mod us <> 0 Or max Mod us <> 0 us = us - 1 Loop bs = (min * max) / us txtmaxgt.Text = Str(maxgt) txtus.Text = Str(us) txtbs.Text = Str(bs) End Sub . Nhập 5 số nguyên dương. Tính các đại lượng như trên form Dim a (5) As Integer Dim dem As Integer Dim i As Integer. " Next i End Sub Private Sub Command3_Click() Dim i As Integer Dim n n = 5 txtchia2.Text = "" max = a(0) min = a(0) MsgBox Str(min) & "

Ngày đăng: 24/10/2013, 14:20

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan