高一信息技术选修计算的问题(VB程序的)将1张面值为100元的人民币等值换成5元,1元的零钞共40张,要求每种零钞不少于1张,问5元和1元面值的零钞各多少元?用枚举算法实现上述.请编写出完整的编写程序.
2019-04-13
高一信息技术选修计算的问题(VB程序的)
将1张面值为100元的人民币等值换成5元,1元的零钞共40张,要求每种零钞不少于1张,问5元和1元面值的零钞各多少元?
用枚举算法实现上述.请编写出完整的编写程序.
优质解答
Private Sub Form_click()
Dim a5 As Integer,a1 As Integer,K As Integer
K = 0
For a1 = 1 To 100
For a5 = 1 To 20
If a1 + a5 = 40 Then
If a1 + a5 * 5 = 100 Then
K = K + 1
Print K,"一元的:"; a1,"五元的:"; a5
End If
End If
Next
Next
End Sub
Private Sub Form_click()
Dim a5 As Integer,a1 As Integer,K As Integer
K = 0
For a1 = 1 To 100
For a5 = 1 To 20
If a1 + a5 = 40 Then
If a1 + a5 * 5 = 100 Then
K = K + 1
Print K,"一元的:"; a1,"五元的:"; a5
End If
End If
Next
Next
End Sub