Mega Code Archive

 
Categories / Delphi / Games
 

Türkçe 999 trilyonlara kadar basitleştirilmiş sayı-yazı heceleme

{ 1991'de Summer'87 de yaptığım bir sayıyı heceleme örneğinden. 999 Trilyonlara kadar daha basitleştirilmiş heceleme örneği Not : Bir önceki örnek 999 Milyar'a kadar heceliyordu.!!! Bu Kodu daha basitleştirdiğimi zannediyorum, daha da geliştirilebilir. Hata var mı diye baya bi inceledim yok gibi. Hata bulursanız lütfen bildiriniz. Form1 üzerinde iki tane edit (Edit1, Edit2) 1 tane de Button1 koyunuz. Fatih BÜYÜKŞİMŞEK - fatihbs@hotmail.com } unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } Function Yaziyla(v_tutyazi : String): String; public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); begin Edit2.Text:=Yaziyla(Edit1.Text); end; Function TForm1.Yaziyla(v_tutyazi : String): String; const TABAN : array [1..9] of String[6] = ('Bir ', 'İki ', 'Üç ', 'Dört ', 'Beş ', 'Altı ', 'Yedi ', 'Sekiz ', 'Dokuz '); ONDALIK : array [1..9] of String[7] = ('On ', 'Yirmi ', 'Otuz ', 'Kırk ', 'Elli ', 'Altmış ', 'Yetmiş ', 'Seksen ', 'Doksan '); var A,C,E : Integer; B,F,gh_yaz1 : String; Bol : Integer; begin if (TrimRight(v_tutyazi)='0') or (v_tutyazi='') then begin gh_yaz1:='Sıfır '; Result:=gh_yaz1; end else begin A:=0; B:=''; C:=0; E:=0; F:=''; gh_yaz1:= ''; C:= Length(TRIMleft(v_tutyazi)); B:= v_tutyazi; E:= C; WHILE E >= 1 do begin F:= Copy(B,C-E+1,1); if f='0' then begin if e=13 then gh_yaz1:= gh_yaz1+'Trilyon '; if e=10 then begin if (StrToInt(Copy(b,c-e,1)) = 0) and (StrToInt(Copy(b,c-e-1,1)) = 0) then bol:=bol+1 else gh_yaz1:= gh_yaz1+'Milyar '; end; if e=7 then begin if (StrToInt(Copy(b,c-e,1)) = 0) and (StrToInt(Copy(b,c-e-1,1)) = 0) then bol:=bol+1 else gh_yaz1:= gh_yaz1+'Milyon '; end; if e=4 then begin if (StrToInt(Copy(b,c-e,1)) = 0) and (StrToInt(Copy(b,c-e-1,1)) = 0) then bol:=bol+1 else gh_yaz1:= gh_yaz1+'Bin '; end; e:=e-1; end else begin if (E = 12) OR (E = 9) OR (E = 6) OR (E = 3) or (e = 15) then begin IF StrToInt(F) = 1 then gh_yaz1:= gh_yaz1+'Yüz ' ELSE gh_yaz1:= gh_yaz1+TABAN[StrToInt(F)]+'Yüz '; end; if (E = 11) OR (E = 8) OR (E = 5) OR (E=2) or (e = 14) then gh_yaz1:= gh_yaz1+ONDALIK[StrToInt(F)]; if E = 13 then gh_yaz1:= gh_yaz1+TABAN[StrToInt(F)]+'Trilyon '; if E = 10 then gh_yaz1:= gh_yaz1+TABAN[StrToInt(F)]+'Milyar '; if E = 7 then gh_yaz1:= gh_yaz1+TABAN[StrToInt(F)]+'Milyon '; if E = 4 then begin IF StrToInt(f) = 1 then gh_yaz1:= gh_yaz1+'Bin ' ELSE gh_yaz1:= gh_yaz1+TABAN[StrToInt(F)]+'Bin '; END; if E = 1 then gh_yaz1:= gh_yaz1+TABAN[StrToInt(F)]; e:= e - 1 end; end; end; result:=gh_yaz1; end; end.