program bt3;
uses crt;
var n: integer;
dem: byte;
chucngan,ngan,tram,chuc,donvi: byte;
begin
writeln('Nhap n = :'); read(n);
if n < 0 then repeat writeln('Nhap n > 0'); read(n) until n >=0;
while n >= 0 do
dem:=0;
begin
n:=n div 10; dem:=dem+1;
end;
case dem of
1: begin
if n = 1 then writeln('mot');
if n = 2 then writeln('hai');
if n = 3 then writeln('ba');
if n = 4 then writeln('bon');
if n = 5 then writeln('nam');
if n = 6 then writeln('sau');
if n = 7 then writeln('bay');
if n = 8 then writeln('tam');
if n = 9 then writeln('chin');
end;
2: begin
chuc:= n div 10;
case chuc of
1: writeln('muoi');
2: writeln('hai muoi ');
3: writeln('ba muoi ');
4: writeln('bon muoi ');
5: writeln('nam muoi');
6: writeln('sau muoi');
7: writeln('bay muoi');
8: writeln('tam muoi');
9: writeln('chin muoi ');
donvi:=n mod 10;
case donvi of
0: writeln(' ');
1: writeln('mot');
2: writeln('hai');
3: writeln('ba');
4: writeln('bon');
5: writeln('lam');
6: writeln('sau');
7: writeln('bay');
8: writeln('tam');
9: writeln('chin');
end;
3: begin
tram:= n div 100;
case tram of
1: writeln('mot tram ');
2: writeln('hai tram');
3: writeln('ba tram');
4: writeln('bon tram');
5: writeln('lam tram');
6: writeln('sau tram');
7: writeln('bay tram');
8: writeln('tam tram');
9: writeln('chin tram');
n:= n mod 100;
chuc:= n div 10;
case chuc of
1: writeln('muoi');
2: writeln('hai muoi ');
3: writeln('ba muoi ');
4: writeln('bon muoi ');
5: writeln('nam muoi');
6: writeln('sau muoi');
7: writeln('bay muoi');
8: writeln('tam muoi');
9: writeln('chin muoi ');
donvi:=n mod 10;
case donvi of
0: writeln(' ');
1: writeln('mot');
2: writeln('hai');
3: writeln('ba');
4: writeln('bon');
5: writeln('lam');
6: writeln('sau');
7: writeln('bay');
8: writeln('tam');
9: writeln('chin');
4: begin
ngan:=n div 1000;
case ngan of
1: writeln('mot ngan');
2: writeln('hai ngan');
3: writeln('ba ngan');
4: writeln('bon ngan');
5: writeln('nam ngan');
6: writeln('sau ngan');
7: writeln('bay ngan');
8: writeln('tam ngan');
9: writeln('chin ngan');
n:= n mod 1000;
tram:= n div 100;
case tram of
1: writeln('mot tram ');
2: writeln('hai tram');
3: writeln('ba tram');
4: writeln('bon tram');
5: writeln('nam tram');
6: writeln('sau tram');
7: writeln('bay tram');
8: writeln('tam tram');
9: writeln('chin tram');
n:=n mod 100;
chuc:= n div 10;
case chuc of
1: writeln('muoi');
2: writeln('hai muoi ');
3: writeln('ba muoi ');
4: writeln('bon muoi ');
5: writeln('nam muoi');
6: writeln('sau muoi');
7: writeln('bay muoi');
8: writeln('tam muoi');
9: writeln('chin muoi ');
donvi:= n mod 10;
case donvi of
0: writeln(' ');
1: writeln('mot');
2: writeln('hai');
3: writeln('ba');
4: writeln('bon');
5: writeln('lam');
6: writeln('sau');
7: writeln('bay');
8: writeln('tam');
9: writeln('chin');
end;
5: begin
chucngan:=n div 10000;
case chucngan of
1: writeln('muoi ngan');
2: writeln('hai muoi');
3: writeln('ba muoi');
4: writeln('bon muoi');
5: writeln('nam muoi');
6: writeln('sau muoi');
7: writeln('bay muoi');
8: writeln('tam muoi ');
9: writeln('chin muoi');
n:= n mod 10000;
ngan:=n div 1000;
case ngan of
1: writeln('mot ngan');
2: writeln('hai ngan');
3: writeln('ba ngan');
4: writeln('bon ngan');
5: writeln('nam ngan');
6: writeln('sau ngan');
7: writeln('bay ngan');
8: writeln('tam ngan');
9: writeln('chin ngan');
n:= n mod 1000;
tram:= n div 100;
case tram of
1: writeln('mot tram ');
2: writeln('hai tram');
3: writeln('ba tram');
4: writeln('bon tram');
5: writeln('nam tram');
6: writeln('sau tram');
7: writeln('bay tram');
8: writeln('tam tram');
9: writeln('chin tram');
n:= n mod 100;
chuc:= n div 10;
case chuc of
1: writeln('muoi');
2: writeln('hai muoi ');
3: writeln('ba muoi ');
4: writeln('bon muoi ');
5: writeln('nam muoi');
6: writeln('sau muoi');
7: writeln('bay muoi');
8: writeln('tam muoi');
9: writeln('chin muoi ');
donvi:= n mod 10;
case donvi of
0: writeln(' ');
1: writeln('mot');
2: writeln('hai');
3: writeln('ba');
4: writeln('bon');
5: writeln('lam');
6: writeln('sau');
7: writeln('bay');
8: writeln('tam');
9: writeln('chin');
end;
6: writelnngan:=n div 1000;
case ngan of
1: writeln('mot ngan');
2: writeln('hai ngan');
3: writeln('ba ngan');
4: writeln('bon ngan');
5: writeln('nam ngan');
6: writeln('sau ngan');
7: writeln('bay ngan');
8: writeln('tam ngan');
9: writeln('chin ngan');
tram:= n div 100;
case tram of
1: writeln('mot tram ');
2: writeln('hai tram');
3: writeln('ba tram');
4: writeln('bon tram');
5: writeln('nam tram');
6: writeln('sau tram');
7: writeln('bay tram');
8: writeln('tam tram');
9: writeln('chin tram');
chuc:= n div 10;
case chuc of
1: writeln('muoi');
2: writeln('hai muoi ');
3: writeln('ba muoi ');
4: writeln('bon muoi ');
5: writeln('nam muoi');
6: writeln('sau muoi');
7: writeln('bay muoi');
8: writeln('tam muoi');
9: writeln('chin muoi ');
case donvi of
0: writeln(' ');
1: writeln('mot');
2: writeln('hai');
3: writeln('ba');
4: writeln('bon');
5: writeln('lam');
6: writeln('sau');
7: writeln('bay');
8: writeln('tam');
9: writeln('chin');
end;
6: writeln('Mot tram ngan');
readln
end.
LỖI:
source.pas(41,1) Error: Constant and CASE types do not match
source.pas(41,1) Error: Constant Expression expected
source.pas(41,1) Fatal: Syntax error, ":" expected but "CASE" found