задача такая: Cоставить программу определяющюю сдачу с рубля наименьшим количеством монет.
Используемые монеты: 1коп, 2коп, 3коп, 5коп, 10коп, 15коп, 20коп, 50коп
program Pr1;
const
Nmonet=8;
type
Tmassive=array[1..Nmonet] of real;
var
sdaha,price:real;
monet:Tmassive;
numb:integer;
function Podshet(const rnd:real):integer;
var
tmp:real;
i,count:integer;
begin
count:=0;
tmp:=rnd;
i:=1;
repeat
if tmp-monet[i]>=0 then
begin
tmp:=tmp-monet[i];
count:=count+1;
end
else
i:=i+1;
until tmp=0 ;
Podshet:=count;
end;
procedure fillMass;
begin
monet[1]:=0.5;
monet[2]:=0.2;
monet[3]:=0.15;
monet[4]:=0.1;
monet[5]:=0.05;
monet[6]:=0.03;
monet[7]:=0.02;
monet[8]:=0.01;
end;
begin
fillMass;
writeln('Vvedite LLEHY TOBAPA');
readln (price);
sdaha:=1-price;
numb:=Podshet(sdaha);
writeln(numb);
readln;
end.
program Pr1;
const
Nmonet=8;
type
Tmassive=array[1..Nmonet] of integer;
const
monet:Tmassive = (50, 20, 15, 10, 5, 3, 2, 1);
var
price: integer;
count, total: integer;
i: integer;
begin
writeln('Vvedite LLEHY TOBAPA');
readln (price);
i := 1;
while price > 0 do begin
count := 0;
while price >= count * monet[i] do inc(count);
dec(count);
if count > 0 then begin
writeln(count, ' coins of ', monet[i]);
dec(price, count * monet[i]);
inc(total, count);
end;
inc(i);
end;
writeln('total coins: ', total);
readln;
end.