用VB!100块买100支笔,其中钢笔3元,圆珠笔2元,铅笔0.5元,问可以买到三种笔各多少支?
用VB!100块买100支笔,其中钢笔3元,圆珠笔2元,铅笔0.5元,问可以买到三种笔各多少支?...
用VB!100块买100支笔,其中钢笔3元,圆珠笔2元,铅笔0.5元,问可以买到三种笔各多少支?
展开
1个回答
展开全部
Private Sub Form_Load()
Dim Xv As Integer, Yv As Integer, Zv As Integer
Dim Pv As Boolean
For i% = 2 To 100 Step 2
Zv = i%
For Y% = 1 To 100
Xv = Y%
Yv = 100 - Xv - Zv
If Yv > 0 Then
If (Xv * 3 + Yv * 2 + Zv * 0.5) = 100 Then
Pv = True
Form1.Print Xv, Yv, Zv
End If
End If
Next Y%
Next i%
End Sub
Dim Xv As Integer, Yv As Integer, Zv As Integer
Dim Pv As Boolean
For i% = 2 To 100 Step 2
Zv = i%
For Y% = 1 To 100
Xv = Y%
Yv = 100 - Xv - Zv
If Yv > 0 Then
If (Xv * 3 + Yv * 2 + Zv * 0.5) = 100 Then
Pv = True
Form1.Print Xv, Yv, Zv
End If
End If
Next Y%
Next i%
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询