Private Sub CommandButton1_Click()
Dim s As Integer, z As Integer
Dim t As String
t = "Для оплате в кассе необходимы:"
s = CInt(InputBox("Введите сумму оплаты"))
Do While s > 0
If s >= 500 Then
s = s - 500: k = k + 1
ElseIf s >= 200 Then
s = s - 200: m = m + 1
ElseIf s >= 100 Then
s = s - 100: n = n + 1
ElseIf s >= 50 Then
s = s - 50: z = z + 1
ElseIf s >= 10 Then
s = s - 10: v = v + 1
ElseIf s >= 5 Then
s = s - 5: h = h + 1
ElseIf s >= 2 Then
s = s - 2: f = f + 1
ElseIf s >= 1 Then
s = s - 1: d = d + 1
End If
Loop
If k > 0 Then
t = t + " " & k & " по 500 рублей, "
t = t + " " & m & " по 200 рублей, "
t = t + " " & n & " по 100 рублей, "
t = t + " " & z & " по 50 рублей, "
t = t + " " & v & " по 10 рублей, "
t = t + " " & h & " по 5 рублей, "
t = t + " " & f & " по 2 рублей, "
t = t + " " & d & " по 1 рублей, "
Cells(10, 1) = t
End Sub
Решение, что называется, "в лоб"
var s,k1,k5,k10,k50,k100,k500,k1000,k10000:integer;
begin
write('s = '); readln(s);
k1:=0; k5:=0; k10:=0; k50:=0;
k100:=0; k500:=0; k1000:=0; k10000:=0;
while s>=10000 do begin s:=s-10000; k10000:=k10000+1; end;
while s>=1000 do begin s:=s-1000; k1000:=k1000+1; end;
while s>=500 do begin s:=s-500; k500:=k500+1; end;
while s>=100 do begin s:=s-100; k100:=k100+1; end;
while s>=50 do begin s:=s-50; k50:=k50+1; end;
while s>=10 do begin s:=s-10; k10:=k10+1; end;
while s>=5 do begin s:=s-5; k5:=k5+1; end;
while s>=1 do begin s:=s-1; k1:=k1+1; end;
writeln('k10000=',k10000,' k1000=',k1000,' k500=',k500,' k100=',k100,' k50=',k50,' k10=',k10,' k5=',k5,' k1=',k1);
writeln(' Всего купюр = ',k1+k5+k10+k50+k100+k500+k1000+k10000);
end.
Подробнее - на -
Private Sub CommandButton1_Click()
Dim s As Integer, z As Integer
Dim t As String
t = "Для оплате в кассе необходимы:"
s = CInt(InputBox("Введите сумму оплаты"))
Do While s > 0
If s >= 500 Then
s = s - 500: k = k + 1
ElseIf s >= 200 Then
s = s - 200: m = m + 1
ElseIf s >= 100 Then
s = s - 100: n = n + 1
ElseIf s >= 50 Then
s = s - 50: z = z + 1
ElseIf s >= 10 Then
s = s - 10: v = v + 1
ElseIf s >= 5 Then
s = s - 5: h = h + 1
ElseIf s >= 2 Then
s = s - 2: f = f + 1
ElseIf s >= 1 Then
s = s - 1: d = d + 1
End If
Loop
If k > 0 Then
t = t + " " & k & " по 500 рублей, "
t = t + " " & m & " по 200 рублей, "
t = t + " " & n & " по 100 рублей, "
t = t + " " & z & " по 50 рублей, "
t = t + " " & v & " по 10 рублей, "
t = t + " " & h & " по 5 рублей, "
t = t + " " & f & " по 2 рублей, "
t = t + " " & d & " по 1 рублей, "
Cells(10, 1) = t
End If
End Sub
Решение, что называется, "в лоб"
var s,k1,k5,k10,k50,k100,k500,k1000,k10000:integer;
begin
write('s = '); readln(s);
k1:=0; k5:=0; k10:=0; k50:=0;
k100:=0; k500:=0; k1000:=0; k10000:=0;
while s>=10000 do begin s:=s-10000; k10000:=k10000+1; end;
while s>=1000 do begin s:=s-1000; k1000:=k1000+1; end;
while s>=500 do begin s:=s-500; k500:=k500+1; end;
while s>=100 do begin s:=s-100; k100:=k100+1; end;
while s>=50 do begin s:=s-50; k50:=k50+1; end;
while s>=10 do begin s:=s-10; k10:=k10+1; end;
while s>=5 do begin s:=s-5; k5:=k5+1; end;
while s>=1 do begin s:=s-1; k1:=k1+1; end;
writeln('k10000=',k10000,' k1000=',k1000,' k500=',k500,' k100=',k100,' k50=',k50,' k10=',k10,' k5=',k5,' k1=',k1);
writeln(' Всего купюр = ',k1+k5+k10+k50+k100+k500+k1000+k10000);
end.
Подробнее - на -