Создайте программу в которой в одномерном массиве осуществляется поиск максимального, минимального элемента, подсчитывается количество отрицательных и количество положительных элементов.(паскаль)
program SearchMinMaxCount; const N = 10; var arr: array[1..N] of integer; i, max, min, countNegative, countPositive: integer; begin max := -9999; min := 9999; countNegative := 0; countPositive := 0;
writeln('Enter ', N, ' integer numbers:'); for i := 1 to N do begin readln(arr[i]); if arr[i] > max then max := arr[i]; if arr[i] < min then min := arr[i]; if arr[i] < 0 then countNegative := countNegative + 1 else if arr[i] > 0 then countPositive := countPositive + 1; end;
writeln('Maximum: ', max); writeln('Minimum: ', min); writeln('Number of negative elements: ', countNegative); writeln('Number of positive elements: ', countPositive); end.
program SearchMinMaxCount;
const
N = 10;
var
arr: array[1..N] of integer;
i, max, min, countNegative, countPositive: integer;
begin
max := -9999;
min := 9999;
countNegative := 0;
countPositive := 0;
writeln('Enter ', N, ' integer numbers:');
for i := 1 to N do
begin
readln(arr[i]);
if arr[i] > max then
max := arr[i];
if arr[i] < min then
min := arr[i];
if arr[i] < 0 then
countNegative := countNegative + 1
else if arr[i] > 0 then
countPositive := countPositive + 1;
end;
writeln('Maximum: ', max);
writeln('Minimum: ', min);
writeln('Number of negative elements: ', countNegative);
writeln('Number of positive elements: ', countPositive);
end.