Professional Documents
Culture Documents
Lập Trình Pascal (Ôn Thi Hsg) Chương Trình Nhập Và Xuất Hóa Đơn Bán Lẻ, Ghi Kết Quả Dưới Định Dạng Số Tiền Và Đọc Số Tiền Thành Chữ
Lập Trình Pascal (Ôn Thi Hsg) Chương Trình Nhập Và Xuất Hóa Đơn Bán Lẻ, Ghi Kết Quả Dưới Định Dạng Số Tiền Và Đọc Số Tiền Thành Chữ
dấu. }
uses crt;
procedure vietso(so:integer);
var z:integer;
begin
z:=so;
if (z>99) and (z<1000) then write(z);
if (z>9) and (z<100) then write('0',z);
if (z<10) then write('00',z);
end;
procedure docso(x:integer);
var tr,ch,dvi,l:integer;
begin
tr:= x div 100;
ch:= (x-100*tr) div 10;
dvi:= x mod 100 - 10*ch;
IF (wherex=13) then begin
Case tr of
1: write('Một');
2: write('Hai');
3: write('Ba');
4: write('Bốn');
5: write('Năm');
6: write('Sáu');
7: write('Bảy');
8: write('Tám');
9: write('Chín');
end;
if (tr<>0) then if (ch<>0) then write(' trăm ') else write('
trăm');
if (tr=0) then
case ch of
1:if (dvi<>0) then write('Mười ') else write('Mười');
2: write('Hai');
3: write('Ba');
4: write('Bốn');
5: write('Năm');
6: write('Sáu');
7: write('Bảy');
8: write('Tám');
9: write('Chín');
end
else
case ch of
0:if (tr<>0) and (dvi<>0) then write(' linh ');
1:if (dvi<>0) then write('mười ') else write('mười');
2: write('hai');
3: write('ba');
4: write('bốn');
5: write('năm');
6: write('sáu');
7: write('bảy');
8: write('tám');
9: write('chín');
end;
if (ch<>1) and (ch<>0) then if (dvi<>0) then write(' mươi
') else write(' mươi');
if (tr+ch=0) then
case dvi of
1: if (ch<2) then write('Một') else write('mốt');
2: write('Hai');
3: write('Ba');
4: if (ch<2) then write('Bốn') else write('tư');
5: if (ch<1) then write('Năm') else write('lăm');
6: write('Sáu');
7: write('Bảy');
8: write('Tám');
9: write('Chín');
end
else
case dvi of
0: if (ch=0) and (tr=0) then write('không');
1: if (ch<2) then write('một') else write('mốt');
2: write('hai');
3: write('ba');
4: if (ch<2) then write('bốn') else write('tư');
5: if (ch<1) then write('năm') else write('lăm');
6: write('sáu');
7: write('bảy');
8: write('tám');
9: write('chín');
end;
end
else
begin
Case tr of
0: begin
if (wherex>18) and (ch<>0) then write('không trăm ');
if (wherex>18) and (ch=0) and (dvi<>0) then
write('không trăm linh ') end;
1: write('một');
2: write('hai');
3: write('ba');
4: write('bốn');
5: write('năm');
6: write('sáu');
7: write('bảy');
8: write('tám');
9: write('chín');
end;
if (tr<>0) then if (ch<>0) then write(' trăm ') else write('
trăm');
case ch of
0:if (tr<>0) and (dvi<>0) then write(' linh ');
1:if (dvi<>0) then write('mười ') else write('mười');
2: write('hai');
3: write('ba');
4: write('bốn');
5: write('năm');
6: write('sáu');
7: write('bảy');
8: write('tám');
9: write('chín');
end;
if (ch<>1) and (ch<>0) then if (dvi<>0) then write(' mươi
') else write(' mươi');
case dvi of
0: if (ch=0) and (tr=0) then write('không');
1: if (ch<2) then write('một') else write('mốt');
2: write('hai');
3: write('ba');
4: if (ch<2) then write('bốn') else write('tư');
5: if (ch<1) then write('năm') else write('lăm');
6: write('sáu');
7: write('bảy');
8: write('tám');
9: write('chín');
end;
end;
end;
var
vat,s,i,j,n,c,d,m,h,r,p,t,o,f,s1,s2,s3,s4,s5,s6,s7,s8,s9,p1,p2,
p3,p4,p5,p6,p7,p8,p9,v,m1,m2,n1,n3,n2,n4,n5,n6,k:int64
;
L,G: array [1..1000] of int64;
begin
clrscr;
s:=0;
write('Số mặt hàng: '); readln(n);clrscr; writeln;
for i:=1 to n do
begin
j:=i;
writeln('-) Mặt hàng (',i,'): ');
write('+) Số lượng: '); readln(l[i]);
write('+) Đơn giá: '); read(g[j]); p:=g[j]; gotoxy(13,wherey-
1);
if (p<1000) then write(p);
if (p>999) and (p<1000000) then begin
p1:= p div 1000;
p2:= p -1000*p1;
write(p1); write(','); vietso(p2); end;
if (p>999999) and (p<1000000000) then begin
p1:= p div 1000000;
p2:=(p-1000000*p1) div 1000;
p3:=p-1000000*p1-1000*p2;
write(p1); write(','); vietso(p2); write(','); vietso(p3); end;
if (p>999999999) then
begin p1:=p div 1000000000;
p2:=(p-p1*1000000000) div 1000000;
p3:=(p-1000000000*p1-1000000*p2) div 1000;
p4:= p- 1000000000*p1-1000000*p2-1000*p3;
write(' ₫');
writeln;
writeln;
write('THÀNH TIỀN: ');
if (s<1000) then docso(s);
if (s>999) and (s<1000000) then
begin
n1:= s div 1000;
n2:= s mod 1000;
docso(n1); if (n2<>0) then write(' nghìn ') else write('
nghìn'); if (n2>0) then docso(n2);
end;
if (s>999999) and (s<1000000000) then
begin
n1:= s div 1000000;
n2:= (s mod 1000000) div 1000;
n3:= (s-(s div 1000000)*1000000) mod 1000;
docso(n1); if (n2+n3<>0) then write(' triệu ') else write('
triệu');
if (n2>0) then begin
docso(n2);if (n3<>0) then write(' nghìn ') else write('
nghìn'); end;
if (n3>0) then
docso(n3);
end;
if (s>999999999) then
begin
m1:= s div 1000000000;
m2:= s mod 1000000000;
n1:= m1 div 1000000;
n2:= (m1 mod 1000000) div 1000;
n3:= (m1-(m1 div 1000000)*1000000) mod 1000;
if (n1<>0) then begin docso(n1);
if (n3>0) then
docso(n3);
if (m2<>0) then write(' tỷ ') else write(' tỷ');
if (n6>0) then
docso(n6);
end;
end;
write(' đồng.');
readln
end.