求简单的VB设计习题
发布网友
发布时间:2024-03-07 09:15
我来回答
共2个回答
热心网友
时间:2024-03-12 01:41
Private Sub Form_Click()
Dim i, j As Double
j = 0
For i = 10 To 500
If i Mod 2 = 0 Then
j = j + i
End If
Next
Print"10到500间的偶数和为:" j
End Sub
----------------------------
Private Sub Form_Click()
Dim i, j, k, z, sum As Integer
For i = 1 To 9
For j = 0To 9
For k = 0 To 9
z = i * i * i + j * j * j + k * k * k
If z = i * 100 + j * 10 + k Then
sum = sum + z
Print z
End If
Next
Next
Next
Print "总和是:"; sum
End Sub
-------------------------------
Private Sub Form_Click()
Dim x, y, z As Integer
For x = -150 To 150
For y = -100 To 100
If 8 * x - 5 * y = 3 Then
z = z + 1
End If
Next
Next
Print "答案共有"; z; "组"
End Sub
---------------------------------------------
Private Sub Form_Click()
Dim i, j, k, l, m, n, Z As Long
For i = 1 To 9
For j = 0 To 9
For k = 0 To 9
For l = 0 To 9
For m = 0 To 9
If i * i + j * j + k * k + l * l + m * m = 110 Then
n = i * 10000 + j * 1000 + k * 100 + l * 10 + m
If n > Z Then
Z = n
End If
End If
Next
Next
Next
Next
Next
Print "最大的五位数是:"; Z
End Sub
---------------------------------
Private Sub Form_Click()
Dim i, j As Integer
For i = 100 To 650
If i Mod 3 = 0 And i Mod 7 = 0 Then
j = j + 1
End If
Next
Print "100到650之间能同时被3和7整除的数的个数是:"; j; "个"
End Sub
----------------------------------------------
'所谓回文数是从左至右与从右至左读起来都是一样的数字,如:121是一个
'回文数。编写程序,求在500-900的范围内所有能被3整除的回文数的个数。
Private Sub Form_Click()
Dim i, j, k, z As Integer
For i = 5 To 8
For j = 0 To 9
z = i * 100 + j * 10 + i
If z Mod 3 = 0 Then
Print z
k = k + 1
End If
Next
Next
Print k
End Sub
----------------------------------
'已知A,B为正整数, A<B, A*B=2198,且要求A+B取最小值,求满足上述条件的A值。
'这个算法还是有问题,计算时太慢了。你再研究一下,我上班没时间。
Private Sub Form_Click()
Dim A, B, z, X, Y, Min As Integer
A = 1
Min = 2199
For B = 1 To 2198
For A = 1 To 2198
If A * B = 2198 Then
z = A + B
If Min > z And A < B Then
Min = z
X = A
Y = B
End If
End If
Next
Next
Print "最小的A+B是:"; X; " +"; Y; "="; Min
End Sub
热心网友
时间:2024-03-12 01:39
不太懂到底要什么东西!