Pascal
Modified: Wednesday, 22-12-2021 07:00 AM
Đọc giờ trong tiếng Anh
Program How_to_Say_Time;
uses crt;
var h,m:byte;
b:boolean;
Function N2C(n:byte):string;
var s:string;
begin
case n of
0:s:='o`clock';
1:s:='One';
2:s:='Two';
3:s:='Three';
4:s:='Four';
5:s:='Five';
6:s:='Six';
7:s:='Seven';
8:s:='Eight';
9:s:='Nine';
10:s:='Ten';
11:s:='Eleven';
12:s:='Twelve';
15:s:='Fifteen';
20:s:='Twenty';
25:s:='Twenty-Five';
30:s:='Thirty';
35:s:='Thirty-Five';
40:s:='Forty';
45:s:='Forty-Five';
50:s:='Fifty';
55:s:='Fifty-Five';
end;
N2C:=s;
end;
Procedure SayTheTime(h,m:byte);
var a,b:string;
c:byte;
begin
a:=N2C(h);
b:=N2C(m);
writeln('It`s ',h,':',m);
if h=0 then
writeln('It`s Zero ',b)
else
writeln('It`s ',a,' ',b);
writeln('--------------------------');
if m<>0 then
begin
writeln('It`s ',m,' past ',h);
writeln('It`s ',b,' past ',a);
writeln('--------------------------');
end;
if m=15 then
begin
writeln('It`s quarter past ',a);
writeln('--------------------------');
end;
if m=30 then
begin
writeln('It`s half past ',a);
writeln('--------------------------');
end;
if m>30 then
begin
c:=h+1;
if c=13 then c:=1;
writeln('It`s ',(60-m),' to ',c);
writeln('It`s ',n2c(60-m),' to ',n2c(c));
writeln('--------------------------');
if m=45 then
writeln('It`s quarter to ',n2c(c));
end;
end;
BEGIN
textbackground(blue);
textcolor(7);
clrscr;
repeat
writeln('Chuong trinh chi dung khi nhap thoi gian hop le!');
writeln('Nhap Gio = 0 | Phut = 0 de thoat');
writeln('-Gio hop le: 1->12');
writeln('-Phut hop le: 0 5 10 .. 55');
writeln('--------------------------');
write('Nhap gio: ');
readln(h);
write('Nhap phut: ');
readln(m);
writeln('--------------------------');
while (h>12)or(m<0)or(m>55)or((m mod 5)<>0) do
begin
write('Nhap gio: ');
readln(h);
write('Nhap phut: ');
readln(m);
writeln('--------------------------');
end;
SayTheTime(h,m);
readln;
clrscr;
until (h=0) and (m=0);
// readln;
END.