===== PascalABC.NET =====
begin
var n := ReadInteger('n =');
var a := ArrRandom(n, -99, 99);
a.Println;
Println('Результат:', (a.Max + a.Min) / 2)
end.
===== Turbo Pascal =====
program abcd;
uses Crt;
const
nn = 100;
var
i, n, max, min: integer;
a: array[1..nn] of integer;
ClrScr;
Write('n = ');
Readln(n);
Randomize;
max := -32768;
min := 32767;
for i := 1 to n do
a[i] := Random(199) - 99;
Write(a[i], ' ');
if a[i] > max then
max := a[i]
else if a[i] < min then
min := a[i]
end;
Writeln;
Writeln('Результат: ', (max + min) / 2);
ReadKey
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
===== PascalABC.NET =====
begin
var n := ReadInteger('n =');
var a := ArrRandom(n, -99, 99);
a.Println;
Println('Результат:', (a.Max + a.Min) / 2)
end.
===== Turbo Pascal =====
program abcd;
uses Crt;
const
nn = 100;
var
i, n, max, min: integer;
a: array[1..nn] of integer;
begin
ClrScr;
Write('n = ');
Readln(n);
Randomize;
max := -32768;
min := 32767;
for i := 1 to n do
begin
a[i] := Random(199) - 99;
Write(a[i], ' ');
if a[i] > max then
max := a[i]
else if a[i] < min then
min := a[i]
end;
Writeln;
Writeln('Результат: ', (max + min) / 2);
ReadKey
end.