Advertisement
trankhanh47

Số thành Chữ - TUKI2501

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