Программа 1
Описание файла
Файл "Программа 1" внутри архива находится в следующих папках: Программа 1, Отчет. Документ из архива "Программа 1", который расположен в категории "". Всё это находится в предмете "программирование" из 4 семестр, которые можно найти в файловом архиве РТУ МИРЭА. Не смотря на прямую связь этого архива с РТУ МИРЭА, его также можно найти и в других разделах. Архив можно найти в разделе "остальное", в предмете "программирование" в общих файлах.
Онлайн просмотр документа "Программа 1"
Текст из документа "Программа 1"
Задание 1.
На входе 3-х значное число от 100 до 999 в виде строки на английском языке, например: one hundred twenty five. на выходе то же число только цифрами 125 и на староруском языке, в котором 1=А, 2=В, 8=И, 30=Л, 100=Р, 500=Ф.
Листинг программы
function In_StaroRussian(Ch : integer): string;
begin
Result := '';
if Ch - 500 >= 0 then begin
Result := Result + 'Ô';
Ch := Ch - 500;
end;
while Ch >= 100 do begin
Ch := Ch - 100;
Result := Result + 'Ð';
end;
while Ch >= 30 do begin
Ch := Ch - 30;
Result := Result + 'Ë';
end;
while Ch >= 8 do begin
Ch := Ch - 8;
Result := Result + 'È';
end;
while Ch >= 2 do begin
Ch := Ch - 2;
Result := Result + 'Â';
end;
while Ch >= 1 do begin
Ch := Ch - 1;
Result := Result + 'À';
end;
end;
function PerevodChisla(str:string):string;
var
podstroka :string;
proverka, i :integer;
incase : boolean;
begin
podstroka := '';
Result := '';
for i := 1 to length(str) do begin
if str[i] = ' ' then begin
incase := false;
if podstroka = 'twenty' then begin incase := true;
Result := Result + '2';
end;
if podstroka = 'thirty' then begin incase := true;
Result := Result + '3';
end;
if podstroka = 'forty' then begin incase := true;
Result := Result + '4';
end;
if podstroka = 'fifty' then begin incase := true;
Result := Result + '5';
end;
if podstroka = 'sixty' then begin incase := true;
Result := Result + '6';
end;
if podstroka = 'seventy' then begin incase := true;
Result := Result + '7';
end;
if podstroka = 'eighty' then begin incase := true;
Result := Result + '8';
end;
if podstroka = 'ninety' then begin incase := true;
Result := Result + '9';
end;
if podstroka = 'ten' then begin incase := true;
Result := Result + '10';
end;
if podstroka = 'eleven' then begin incase := true;
Result := Result + '11';
end;
if podstroka = 'twelve' then begin incase := true;
Result := Result + '12';
end;
if podstroka = 'thirteen' then begin incase := true;
Result := Result + '13';
end;
if podstroka = 'fourteen' then begin incase := true;
Result := Result + '14';
end;
if podstroka = 'fifteen' then begin incase := true;
Result := Result + '15';
end;
if podstroka = 'sixteen' then begin incase := true;
Result := Result + '16';
end;
if podstroka = 'seventeen' then begin incase := true;
Result := Result + '17';
end;
if podstroka = 'eighteen' then begin incase := true;
Result := Result + '18';
end;
if podstroka = 'nineteen' then begin incase := true;
Result := Result + '18';
end;
if podstroka = 'one' then begin incase := true;
Result := Result + '1';
end;
if podstroka = 'two' then begin incase := true;
Result := Result + '2';
end;
if podstroka = 'thee' then begin incase := true;
Result := Result + '3';
end;
if podstroka = 'four' then begin incase := true;
Result := Result + '4';
end;
if podstroka = 'five' then begin incase := true;
Result := Result + '5';
end;
if podstroka = 'six' then begin incase := true;
Result := Result + '6';
end;
if podstroka = 'seven' then begin incase := true;
Result := Result + '7';
end;
if podstroka = 'eight' then begin incase := true;
Result := Result + '8';
end;
if podstroka = 'nine' then begin incase := true;
Result := Result + '9';
end;
if podstroka = 'hundred' then incase := true;
if incase = false then begin
showmessage('Íàéäåíà îøèáêà â ñëîâå ' + podstroka);
Result := '0';
exit;
end;
podstroka := '';
end
else
podstroka := podstroka + str[i];
end;
if length(result) = 1 then result := result + '00';
if length(result) = 2 then result := result[1] + '0' + result[2];
end;
procedure TForm1.RunClick(Sender: TObject);
var
s:string;
c:integer;
begin
s := Trim(Chislo.text);
s := PerevodChisla(s + ' ');
c := StrToInt(s);
show_chislo.Caption := s;
Res.Text := In_StaroRussian(c);
end;
end.
Скриншоты программы