function currency2Str
(value: double): string;
const hundreds: array
[0..9] of string = ('',' сто','
двести',' триста','
четыреста',' пятьсот','
шестьсот',' семьсот','
восемьсот',' девятьсот');
tens: array [0..9] of string = ('','',' двадцать','
тридцать',' сорок','
пятьдесят',' шестьдесят','
семьдесят',' восемьдесят','
девяносто');
ones: array [0..19] of string = ('','','','
три',' четыре','
пять',' шесть','
семь',' восемь','
девять',' десять','
одиннадцать',' двенадцать','
тринадцать',' четырнадцать','
пятнадцать',' шестнадцать','
семнадцать',' восемнадцать','
девятнадцать');
razryad: array [0..6] of string = ('',' тысяч',' миллион',' миллиард',' триллион',' квадриллион','
квинтиллион');
var s: string; i: integer; val:
int64;
function shortNum(s: string; raz: integer):
string;
begin
Result:=hundreds[StrToInt(s[1])];
if StrToInt(s)=0 then Exit;
if s[2]<>'1' then begin
Result:=Result+tens[StrToInt(s[2])];
case StrToInt(s[3]) of
1: if raz=1
then Result:=Result+' одна' else
Result:=Result+' один';
2: if raz=1
then Result:=Result+' две' else
Result:=Result+' два';
else Result:=Result+ones[StrToInt(s[3])];
end;
Result:=Result+razryad[raz];
case StrToInt(s[3]) of
0,5,6,7,8,9: if raz>1 then
Result:=Result+'ов';
1: if raz=1 then Result:=Result+'а';
2,3,4: if raz=1 then
Result:=Result+'и' else if raz>1 then Result:=Result+'а';
end;
end else begin
Result:=Result+ones[StrToInt(Copy(s,2,2))];
Result:=Result+razryad[raz];
if raz>1 then
Result:=Result+'ов';
end;
end;
begin
val:=Trunc(value);
if val=0 then begin
Result:='ноль'; Exit; end;
s:=IntToStr(val); Result:=''; i:=0;
while Length(s)>0 do
begin
Result:=shortNum(Copy('00'+s,Length('00'+s)-2,3),i)+Result;
if Length(s)>3 then
s:=Copy(s,1,Length(s)-3)
else s:='';
inc(i);
end;
s:=IntToStr(Trunc((value-val)*100+0.5));
Result:=Result+' руб. '+s+' коп.';
end;