• Web sitemizin içeriğine ve tüm hizmetlerimize erişim sağlamak için Web sitemize kayıt olmalı ya da giriş yapmalısınız. Web sitemize üye olmak tamamen ücretsizdir.
  • Sohbetokey.com ile canlı okey oynamaya ne dersin? Hem sohbet et, hem mobil okey oyna!
  • Soru mu? Sorun mu? ''Bir Sorum Var?'' sistemimiz aktiftir. Paylaşın beraber çözüm üretelim.

Sayıyı yazıya çeviren fonksiyon

Üyelik Tarihi
7 Ocak 2015
Konular
4,091
Mesajlar
4,274
MFC Puanı
40
Kod:
Const
  BIRLER            : Array[0..9] Of String = ('', 'Bir', 'İki', 'Üç', 'Dört', 'Beş', 'Altı',
    'Yedi', 'Sekiz', 'Dokuz');
  ONLAR             : Array[0..9] Of String = ('', 'On', 'Yirmi', 'Otuz', 'Kırk', 'Elli', 'Altmış',
    'Yetmis', 'Seksen', 'Doksan');
  DIGER             : Array[0..5] Of String = ('', 'Bin', 'Milyon', 'Milyar', 'Trilyon', 'Katrilyon');


Function uSayiyiYaziyaCevir(Num : Double) : String;


  Function SmallNum(Num : Int64) : String;
  Var
    S               : String[3];
  Begin
    Result := '';
    S := IntToStr(Num);
    If (Length(S) = 1) Then
      S := '00' + S
    Else
      If (Length(S) = 2) Then
        S := '0' + S;
    If S[1] <> '0' Then
      If S[1] <> '1' Then
        Result := BIRLER[StrToInt(S[1])] + 'Yüz'
      Else
        Result := 'Yüz';
    Result := Result + ONLAR[StrToInt(S[2])];
    Result := Result + BIRLER[StrToInt(S[3])];
  End;


Var
  i, j, n, Nm       : Int64;
  S, Sn             : String;


Begin
  S := FormatFloat('0', Num);
  Sn := '';
  If Num = 0 Then
    Sn := 'Sıfır'
  Else
    If Length(S) < 4 Then
      //      Sn := SmallNum(RountNum)
      Sn := SmallNum(Round(Num))
    Else
    Begin
      I := 1;
      J := Length(S) Mod 3;
      If J = 0 Then
      Begin
        J := 3;
        N := Length(S) Div 3 - 1;
      End
      Else
        N := Length(S) Div 3;
      While i < Length(S) Do
      Begin
        Nm := StrToInt(Copy(S, I, J));
        If (Nm = 1) And (N = 1) Then
        Begin
          Nm := 0;
          Sn := Sn + SmallNum(Nm) + Diger[N];
        End;
        If Nm <> 0 Then
          Sn := Sn + SmallNum(Nm) + Diger[N];
        I := I + J;
        J := 3;
        N := N - 1;
      End;
    End;
  Result := Sn;
End;
// örnek
procedure TForm1.Button2Click(Sender: TObject);
begin
ShowMessage( uSayiyiYaziyaCevir(78974642));
end;


end.
 
Üst