Tải bản đầy đủ (.docx) (2 trang)

Một số bài pascal hay và thường xuất hiện trong các đề thi

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (35.93 KB, 2 trang )

*ĐỀ: Viết chương trình nhập vào số nguyên n (n<1000).
Hãy đưa ra cách đọc số đó bằng tiếng Việt không dấu.
Chú ý: phân biệt cách ghi mốt với một.
mốt: mo't
một: mot
Ví dụ:
n = 761
Bay tram sau muoi mo't

*CODE:
uses crt;
var a:array[0..9] of string;
nn,l,k,m,n:integer;
begin
clrscr;
write('N=');readln(n);
nn:=n;
m:=n div 100;
n:=n mod 100;
k:=n div 10;
l:=n mod 10;
a[0]:=' ';a[1]:='mot'; a[2]:='hai';a[3]:='ba'; a[4]:='bon';a[5]:='nam';
a[6]:='sau';a[7]:='bay'; a[8]:='tam';a[9]:='chin';
if nn>=100 then
begin
if (k=0) and (l=0) then
write(a[m],' tram ')
else
begin
write(a[m],' tram ');
if (k<>0) and (k<>1) then


begin
write(a[k],' muoi ');
if l=1 then write('mo''t')
else if l=5 then write('lam')


else write(a[l]);
end
else if k=0 then write('le ', a[l])
else if k=1 then write ('muoi ',a[l]);
end;
end
else if nn>=10 then
begin
if k<>1 then
begin
write(a[k],' muoi ');
if l=1 then write('mo''t')
else if l=5 then write('lam')
else write(' ',a[l]);
end
else if k=1 then
begin
if l<>5 then write('muoi ',a[l])
else write('muoi lam');
end;
end
else write(a[l]);
readln;
end.




×