Skip to content

Instantly share code, notes, and snippets.

@Kanol
Created October 9, 2016 16:11
Show Gist options
  • Save Kanol/6bc9e98bc07e4f63ef5d07153e860fb2 to your computer and use it in GitHub Desktop.
Save Kanol/6bc9e98bc07e4f63ef5d07153e860fb2 to your computer and use it in GitHub Desktop.
program n6;
var number, ed, des, sot, tis:integer;
res:string;
function lang(var num:integer; tip:string):string;
begin
case num of
1:case tip of
'ed':result:='Один';
'des':result:=lang(num, 'ed')+'надцать ';
'sot':result:='Сто ';
'tis':result:='Одна тысяча ';
end;
2:case tip of
'ed':result:='Два';
'des':result:=lang(num, 'ed')+'дцать ';
'sot':result:='Двести ';
'tis':result:='Две тысячи ';
end;
3:case tip of
'ed':result:='Три';
'des':result:=lang(num, 'ed')+'дцать ';
'sot':result:=lang(num, 'ed')+'ста ';
'tis':result:=lang(num, 'ed')+' тысячи ';
end;
4:case tip of
'ed':result:='Четыре';
'des':result:='Сорок ';
'sot':result:=lang(num, 'ed')+'ста ';
'tis':result:=lang(num, 'ed')+' тысячи ';
end;
5:case tip of
'ed':result:='Пять';
'des':result:=lang(num, 'ed')+'десят ';
'sot':result:=lang(num, 'ed')+'сот ';
'tis':result:=lang(num, 'ed')+' тысяч ';
end;
6:case tip of
'ed':result:='Шесть';
'des':result:=lang(num, 'ed')+'десят ';
'sot':result:=lang(num, 'ed')+'сот ';
'tis':result:=lang(num, 'ed')+' тысяч ';
end;
7:case tip of
'ed':result:='Семь';
'des':result:=lang(num, 'ed')+'десят ';
'sot':result:=lang(num, 'ed')+'сот ';
'tis':result:=lang(num, 'ed')+' тысяч ';
end;
8:case tip of
'ed':result:='Восемь';
'des':result:=lang(num, 'ed')+'десят ';
'sot':result:=lang(num, 'ed')+'сот ';
'tis':result:=lang(num, 'ed')+' тысяч ';
end;
9:case tip of
'ed':result:='Девять';
'des':result:='Девяносто ';
'sot':result:=lang(num, 'ed')+'сот ';
'tis':result:=lang(num, 'ed')+' тысяч ';
end;
end;
end;
function lang1(var ed:integer):string;
begin
case ed of
1:result:='Одиннадцать';
2:result:='Двенадцать';
3:result:='Тринадцать';
4:result:='Четырнадцать';
5:result:='Пятнадцать';
6:result:='Шестнадцать';
7:result:='Семнадцать';
8:result:='Восемнадцать';
9:result:='Девятнадцать';
end;
end;
begin
readln(number);
ed:=number mod 10;
des:= (number mod 100) div 10;
sot:= (number div 100) mod 10;
tis:= number div 1000;
if(tis<>0) then res:=res+lang(tis, 'tis');
if(sot<>0) then res:=res+lang(sot, 'sot');
if(des<>0)and(des<>1) then res:=res+lang(des, 'des');
if(des=1) then res:=res+lang1(ed);
if(ed<>0)and(des<>1) then res:=res+lang(ed, 'ed');
writeln(res);
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment