Var ar:array[1..s] of integer; n,m,i:integer; begin writeln('N'); readln(n); writeln('M'); readln(m); writeln('Array:'); for i:=1 to s do readln(ar[i]); writeln('First array:'); for i:=1 to s do begin write(ar[i]:4); if ar[i] div n<>0 then ar[i]:=ar[i]+m; end; writeln; writeln('Final array:'); for i:=1 to s do write(ar[i]:4); end.
Пример ввода: 3 3 1 2 3 4 5 Пример вывода: First array: 1 2 3 4 5 Final array: 1 2 6 7 8
Const
s=5;
Var
ar:array[1..s] of integer;
n,m,i:integer;
begin
writeln('N');
readln(n);
writeln('M');
readln(m);
writeln('Array:');
for i:=1 to s do
readln(ar[i]);
writeln('First array:');
for i:=1 to s do
begin
write(ar[i]:4);
if ar[i] div n<>0 then ar[i]:=ar[i]+m;
end;
writeln;
writeln('Final array:');
for i:=1 to s do
write(ar[i]:4);
end.
Пример ввода:
3
3
1
2
3
4
5
Пример вывода:
First array:
1 2 3 4 5
Final array:
1 2 6 7 8
//Блок-схема во вложении
--- PascalABC.NET 3.6.2 ---
//Без внятного ТЗ - Результат ХЗ (с) Конфуций, 488 год до Н.Э.
begin
var AvaiableTravels := new List<(string, integer)>(10);
var RawInput: array of string;
for var i := 1 to 10 do begin
RawInput := ReadString($'{i} Enter Travel info (Country:Price)').Split(':');
AvaiableTravels.Add((RawInput[0], integer.Parse(RawInput[1])));
end;
var TotalCost : integer;
var MaxCost: (string, integer) := AvaiableTravels.First;
var MinCost: (string, integer) := AvaiableTravels.Last;
AvaiableTravels.ForEach(p -> begin
TotalCost += p.Item2;
if p.Item2 > MaxCost.Item2 then MaxCost := p;
if p.Item2 < MinCost.Item2 then MinCost := p;
end);
Println($'Total Travel Cost: {TotalCost}',
$'Most expensive Travel: {MaxCost}',
$'Most poor travel: {MinCost}');
end.
Объяснение: