Advertisement
MinhNGUYEN2k4

Untitled

Oct 11th, 2020
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.69 KB | None | 0 0
  1. program Hello;
  2. var money : integer;
  3.     cur : array[1..9] of integer;
  4.     d : array[1..9] of integer;
  5.     i,k : integer;
  6. begin
  7.     writeln('Nhap so tien can tinh: ');
  8.     readln(money);
  9.     k := 0;
  10.     for i:=1 to 9 do d[i] := 0;
  11.     cur[1]:=500;cur[3]:=100;cur[4]:=50;cur[5]:=20;
  12.     cur[2]:=200;cur[6]:=10;cur[7]:=5;cur[8]:=2;cur[9]:=1;
  13.     i := 1;
  14.     while money > 0 do
  15.     begin
  16.         if money >= cur[i] then
  17.         begin
  18.             dec(money,cur[i]);
  19.             inc(d[i]);
  20.         end;
  21.         if money < cur[i] then inc(i);
  22.     end;
  23.  
  24.  
  25.  
  26.     if (d[1] > 0) then writeln('So to 500k la: ',d[1]);
  27.  
  28.  
  29.  
  30. // còn mấy dòng cuối tự ghi lại, y hệt như dòng 500k
  31. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement