- function EnLettres(N:integer):string;
- // TRADUIRE UN NOMBRE EN LETTRES : Limites : de -MaxLongInt À MaxLongInt.
- //[Auteur : Participant, news.vienneinfo.org forum nzn.fr.delphi]
- Const
- Unite:Array[1..16] of String=('un','deux','trois','quatre','cinq','six',
- 'sept','huit','neuf','dix','onze','douze',
- 'treize','quatorze','quinze','seize');
- Dizaine:Array[2..8]of String=('vingt','trente','quarante','cinquante',
- 'soixante','','quatre-vingt');
- Coefs:Array[0..3]of String=('cent','mille','million','milliard');
- Var
- Temp : String;
- C,D,U : Byte;
- Coef : Byte;
- I : Word;
- Neg : Boolean;
- Begin
- If N=0 then
- Begin
- Result:=' zéro';
- Exit;
- End;
- Result:='';
- Neg:= N<0;
- If Neg then N:=-N;
- Coef:=0;
- Repeat
- U:=N mod 10; N:=N div 10; {RÉcupÈre unitÉ et dizaine}
- D:=N mod 10; N:=N div 10; {RÉcupÈre dizaine}
- If D in [1,7,9] then
- Begin
- Dec(D);
- Inc(U,10);
- End;
- Temp:='';
- If D>1 then
- Begin
- Temp:=' '+Dizaine[D];
- If (D<8) and ((U=1) or (U=11)) then
- Temp:=Temp+' et';
- End;
- If U>16 then
- Begin
- Temp:=Temp+' '+Unite[10];
- Dec(U,10);
- End;
- If U>0 then Temp:=Temp+' '+Unite[U];
- If (Result='') and (D=8) and (U=0) then Result:='s';
- Result:=Temp+Result;
- C:=N mod 10; N:=N div 10; {RÉcupÈre centaine}
- If C>0 then
- Begin
- Temp:='';
- If C>1 then Temp:=' '+Unite[C]+Temp;
- Temp:=Temp+' '+Coefs[0];
- If (Result='') and (C>1) then Result:='s';
- Result:=Temp+Result;
- End;
- If N>0 then
- Begin
- Inc(Coef);
- I:=N mod 1000;
- If (I>1) and (Coef>1) then Result:='s'+result;
- If I>0 then Result:=' '+Coefs[Coef]+Result;
- If (I=1) and (Coef=1) then Dec(N);
- End;
- until N=0;
- If Neg then Result:='moins'+result;
- end;
function EnLettres(N:integer):string;
// TRADUIRE UN NOMBRE EN LETTRES : Limites : de -MaxLongInt À MaxLongInt.
//[Auteur : Participant, news.vienneinfo.org forum nzn.fr.delphi]
Const
Unite:Array[1..16] of String=('un','deux','trois','quatre','cinq','six',
'sept','huit','neuf','dix','onze','douze',
'treize','quatorze','quinze','seize');
Dizaine:Array[2..8]of String=('vingt','trente','quarante','cinquante',
'soixante','','quatre-vingt');
Coefs:Array[0..3]of String=('cent','mille','million','milliard');
Var
Temp : String;
C,D,U : Byte;
Coef : Byte;
I : Word;
Neg : Boolean;
Begin
If N=0 then
Begin
Result:=' zéro';
Exit;
End;
Result:='';
Neg:= N<0;
If Neg then N:=-N;
Coef:=0;
Repeat
U:=N mod 10; N:=N div 10; {RÉcupÈre unitÉ et dizaine}
D:=N mod 10; N:=N div 10; {RÉcupÈre dizaine}
If D in [1,7,9] then
Begin
Dec(D);
Inc(U,10);
End;
Temp:='';
If D>1 then
Begin
Temp:=' '+Dizaine[D];
If (D<8) and ((U=1) or (U=11)) then
Temp:=Temp+' et';
End;
If U>16 then
Begin
Temp:=Temp+' '+Unite[10];
Dec(U,10);
End;
If U>0 then Temp:=Temp+' '+Unite[U];
If (Result='') and (D=8) and (U=0) then Result:='s';
Result:=Temp+Result;
C:=N mod 10; N:=N div 10; {RÉcupÈre centaine}
If C>0 then
Begin
Temp:='';
If C>1 then Temp:=' '+Unite[C]+Temp;
Temp:=Temp+' '+Coefs[0];
If (Result='') and (C>1) then Result:='s';
Result:=Temp+Result;
End;
If N>0 then
Begin
Inc(Coef);
I:=N mod 1000;
If (I>1) and (Coef>1) then Result:='s'+result;
If I>0 then Result:=' '+Coefs[Coef]+Result;
If (I=1) and (Coef=1) then Dec(N);
End;
until N=0;
If Neg then Result:='moins'+result;
end;