Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

Дано натуральное . Записать это число русскими словами. от 1 до 1000 на Паскале

slavikk07 Мастер (1492), закрыт 12 лет назад
Лучший ответ
Лара Гений (56353) 12 лет назад
program chislo; {число от 1-1000 записать словами}
Var s:string;
t:string;
begin
writeln('Введите число от 1 до 1000');
readln(s);
if s='1000' then writeln('Одна тысяча') else begin
t:=''; if length(s)=1 then s:='00'+s else if length(s)=2 then s:='0'+s;
if length(s)=3 then begin
if s[1]= '1' then t:=t+'сто ';
if s[1]= '2' then t:=t+'двести ';
if s[1]= '3' then t:=t+'триста ';
if s[1]= '4' then t:=t+'четыреста ';
if s[1]= '5' then t:=t+'пятьсот ';
if s[1]= '6' then t:=t+'шестьсот ';
if s[1]= '7' then t:=t+'семьсот ';
if s[1]= '8' then t:=t+'восемьсот ';
if s[1]= '9' then t:=t+'девятьсот ';

if s[2]= '2' then t:=t+'двадцать ';
if s[2]= '3' then t:=t+'тридцать ';
if s[2]= '4' then t:=t+'сорок ';
if s[2]= '5' then t:=t+'пятьдесят ';
if s[2]= '6' then t:=t+'шестьдесят ';
if s[2]= '7' then t:=t+'семьдесят ';
if s[2]= '8' then t:=t+'восемьдесят ';
if s[2]= '9' then t:=t+'девяносто ';

if s[2]= '1' then begin
if s[3]= '1' then t:=t+'одиннадцать ';
if s[3]= '2' then t:=t+'двенадцать ';
if s[3]= '3' then t:=t+'тринадцать ';
if s[3]= '4' then t:=t+'четырнадцать ';
if s[3]= '5' then t:=t+'пятнадцать ';
if s[3]= '6' then t:=t+'шестнадцать ';
if s[3]= '7' then t:=t+'семнадцать ';
if s[3]= '8' then t:=t+'восемнадцать ';
if s[3]= '9' then t:=t+'девятнадцать ';
end;
if s[2]<> '1' then begin
if s[3]= '1' then t:=t+'один ';
if s[3]= '2' then t:=t+'два ';
if s[3]= '3' then t:=t+'три ';
if s[3]= '4' then t:=t+'четыре ';
if s[3]= '5' then t:=t+'пять ';
if s[3]= '6' then t:=t+'шесть ';
if s[3]= '7' then t:=t+'семь ';
if s[3]= '8' then t:=t+'восемь ';
if s[3]= '9' then t:=t+'девять ';
end; writeln(t); end else writeln('Число не лежит в диапазоне от 1 до 1000')
end;
End.
slavikk07Мастер (1492) 12 лет назад
спасибо!
Остальные ответы
Похожие вопросы