请VB高手解决这个程序问题。
- 提问者网友:刺鸟
- 2021-07-24 03:15
- 五星知识达人网友:迷人又混蛋
- 2021-07-24 03:59
在窗体上添加一个文本框text1,把它的MultiLine属性设置为true,把它的ScrollBars属性设为2-Vertical,然后添加下面的代码,运行即可
Private Sub Form_Load()
Text1.Text = maiJi '显示答案
End Sub
Function maiJi() As String '买鸡的程序实现
Dim xiaoJi As Integer
Dim gongJi As Integer
Dim muJi As Integer
Dim Str As String
Str = ""
For xiaoJi = 0 To 99 Step 3
For gongJi = 0 To 20
For muJi = 0 To 100 - i - j
If (xiaoJi / 3) + 5 * gongJi + 3 * muJi = 100 Then
Str = Str & "买了公鸡" & gongJi & "只,买了母鸡" & muJi & "只,买了小鸡" & xiaoJi & "只" & vbCrLf
End If
Next
Next
Next
maiJi = Str
End Function
- 1楼网友:神的生死簿
- 2021-07-24 05:01
Private Sub Command1_Click() For gj = 0 To 20 For mj = 0 To 33 For xj = 0 To 99 Step 3 If gj * 5 + mj * 3 + xj / 3 = 100 And gj+ mj + xj = 100 Then Print gj, mj, xj End If Next Next Next End Sub
- 2楼网友:英雄的欲望
- 2021-07-24 04:16
Dim i, j, k As Integer
For i = 1 To 100
For j = 1 To 100
For k = 1 To 100
If (i + j + k = 100) And (i * 5 + j * 3 + k / 3 = 100) Then Label1.Caption = CStr(i) + " " + CStr(j) + " " + CStr(k) End If
Next k
Next j
Next i