Advertisement
tuki2501

Số thành Chữ

Oct 14th, 2018
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.98 KB | None | 0 0
  1. uses crt;
  2. type
  3.   chu=(khong,mot,hai,ba,bon,nam,sau,bay,tam,chin);
  4. var
  5.   s:string;
  6.   n:longint;
  7.  
  8. procedure ghichu(i:longint);
  9. var k:longint;
  10. begin
  11.   k:=ord(s[i])-48;
  12.   if (k<>0) or (i<>3) then write(chu(k),' ');
  13. end;
  14.  
  15. function chuyen(i:longint):longint;
  16. begin
  17.   exit(ord(s[i])-48);
  18. end;
  19.  
  20. procedure solve();
  21. begin
  22.   readln(n);
  23.   str(n,s);
  24.   n:=length(s);
  25.   if n=1 then ghichu(1)
  26.   else
  27.     begin
  28.       if n=2 then s:='0'+s;
  29.       if chuyen(1)<>0 then
  30.         begin
  31.           ghichu(1);
  32.           write('tram ');
  33.         end;
  34.       if chuyen(2)<>0 then
  35.         begin
  36.           if chuyen(2)<>1 then
  37.             begin
  38.               ghichu(2);
  39.               write('muoi ');
  40.             end
  41.           else write('muoif ');
  42.           if chuyen(3)=5 then write('lam')
  43.           else ghichu(3);
  44.         end
  45.       else
  46.         begin
  47.           if chuyen(3)<>0 then write('linh ');
  48.           ghichu(3);
  49.         end;
  50.     end;
  51. end;
  52.  
  53. begin
  54.   solve();
  55.   readln();
  56. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement