VB编程:1到100中,三的倍数有几个,7的倍数有几个

感激不尽
2025-01-01 21:19:03
推荐回答(4个)
回答1:

dim i,b,c
b =0
c =0
for i = 1 to 100
if (i mod 3) = 0 then
b = b+1
elseif (i mod 7) = 0 then
c = c+1
end if

next
print "三的倍数有" & b
print "七的倍数有" & c

回答2:

Dim i As Integer
Dim j As Integer
Dim k As Integer
Private Sub Form_Load()
Form1.Show
For i = 1 To 100 Step 1
If i Mod 3 = 0 Then
j = j + 1
End If

Next i

For i = 1 To 100 Step 1
If i Mod 10 = 0 Then
k = k + 1
End If
Next i
Print "3的倍数有" & j
Print "10的倍数有" & k

End Sub

回答3:

Dim i As Integer
Dim j As Integer
Dim k As Integer
Private Sub Form_Load()
For i = 1 To 100
If i Mod 3 = 0 Then
j = j + 1
End If
If i Mod 7 = 0 Then
k = k + 1
End If
Next i

Print "3的倍数有" & j
Print "7的倍数有" & k

End Sub

回答4:

用 for循环 if判断 加取模(MOD)运算 就可以了啊