Vba! переделать алгоритм с цикла по параметру на цикл с пост или с предусловием, сколько можно купить быков,коров , телят, если за b(быков)-10 руб k(коров)-5 руб, t(телят)-0,5 руб, если есть 100 рублей, нужно купить 100 голов скота. sub slot() dim c as double dim c1 as double dim c2 as double dim c3 as double dim z as integer dim b as integer dim t as integer dim n as integer n = 100 ' nado golov c = 100 ' vsego deneg c1 = 10 ' za bika c2 = 5 'za korovy c3 = 0.5 'za telenka for z = 0 to c / c1 for b = 0 to c / c2 for t = 0 to c / c3 if z + b + t = n then if z * c1 + b * c2 + t * c3 = c then msgbox ("bikov: " & z & "korov: " & b & "teliat: " & t) end if end if next t next b next z end sub
Sub slot()
Dim c As Double
Dim c1 As Double
Dim c2 As Double
Dim c3 As Double
Dim z As Integer
Dim b As Integer
Dim T As Integer
Dim n As Integer
n = 100 ' nado golov
c = 100 ' vsego deneg
c1 = 10 ' za bika
c2 = 5 'za korovy
c3 = 0.5 'za telenka
z = 0
Do
b = 0
Do While b <= c / c2
T = 0
Do While T <= c / c3
If z + b + T = n Then
If z * c1 + b * c2 + T * c3 = c Then
MsgBox ("bikov: " & z & "korov: " & b & "Teliat: " & T)
End If
End If
T = T + 1
Loop
b = b + 1
Loop
z = z + 1
Loop Until z > c / c1
End Sub