Св pascal определить стоимость телеграмма если известно количество слов, простая или на открытке или без. открытки : 2 руб. 1 слово: запросить категория: ( +20% от простой)
var mas1, mas2: array[0..9] of integer; t, k, i, j: integer; begin readln(t); readln(k); for j := 0 to 1 do begin if (j = 1) then writeln(); for i := 0 to 9 do begin if(j = 0) then begin mas1[i] := random(100); write(mas1[i], ' '); if mas1[i] > t Then mas1[i] := mas1[i] + 4; end else begin mas2[i] := random(100); write(mas2[i], ' '); if mas2[i] > 10 * K Then mas2[i] := mas2[i] + K; end; end; for i := 0 to 9 do if (j = 0) then write(mas1[i]) else write(mas2[i]); writeln(); end; readln(); end.
program ideone;
uses SysUtils;
function WordsCount(s: string): integer;
var
i, count: Integer;
begin
count := 0;
for i := 1 to Length(s) do
begin
if (s[i] <> ' ') and ((i = 1) or (s[i-1] = ' '))
then inc(count);
end;
WordsCount := count;
end;
var
a: string;
count: Integer;
isUrgent : Integer;
cost: Double;
begin
writeln('Введите строку A: ');
read(a);
count := WordsCount(a);
writeln('Посылка Если да, введите 1, иначе 0: ');
read(isUrgent);
cost := count * 2;
if (isUrgent = 1) then cost := 1.2*cost;
writeln(Format('Стоимость посылки составляет %.2f рублей.', [cost]));
end.