var a,b,c,va,vb,vc: integer;
begin
va:=8; vb:=3; vc:=5;
a:=va; b:=0; c:=0;
write('начальное распределение: ');
writeln('a = ',a,' b = ',b,' c = ',c);
while true do
begin
if ((a>0) and (b
begin
a:=a-(vb-b); b:=vb;
end
else
if (c0) then
begin
b:=b-min((vc-c),vb); c:=c+min((vc-c),vb);
end;
if (c=vc) then
begin
writeln('a = ',a,' b = ',b,' c = ',c);
a:=a+c; c:=0;
writeln('a = ',a,' b = ',b,' c = ',c);
c:=b; b:=0;
end;
writeln('a = ',a,' b = ',b,' c = ',c);
if (a=(va div 2)) then break;
end;
if b+c
begin
c:=c+b; b:=0;
writeln('a = ',a,' b = ',b,' c = ',c);
end;
write('конечное распределение: ');
writeln('a = ',a,' b = ',b,' c = ',c);
end.
начальное распределение: a = 8 b = 0 c = 0
a = 5 b = 3 c = 0
a = 5 b = 0 c = 3
a = 2 b = 3 c = 3
a = 2 b = 1 c = 5
a = 7 b = 1 c = 0
a = 7 b = 0 c = 1
a = 4 b = 3 c = 1
a = 4 b = 0 c = 4
конечное распределение: a = 4 b = 0 c = 4