

СРОЧНО ПОЖАЛУЙСТА ИНФОРМАТИКА ПОМОГИТЕ
С клавиатуры задан массив, состоящий из N элементов целого типа.
Выведите на экран данный массив в строку. Посчитать количество положительных элементов и выведите на экран полученное число.
Лень переписывать под тебя - сам поправишь
Исходный код программы поиска количества положительных и отрицательных элементов массива на языке Pascal:
const N = 10;
var
a: array[1..N] of integer;
i, pos, neg: byte;
begin
randomize;
pos := 0;
neg := 0;
for i := 1 to N do begin
a[i] := random(7) - 3;
write(a[i], ' ');
if a[i] < 0 then
neg := neg + 1
else
if a[i] > 0 then
pos := pos + 1;
end;
writeln;
writeln('Положительных: ', pos);
writeln('Отрицательных: ', neg);
end.
Пример выполнения:
3 1 -3 -3 -1 1 0 0 2 -2
Положительных: 4
Отрицательных: 4
public class Main {
public static void main(String[] args) {
int[] array = {3, -5, 7, -2, 0, 8, -1, 4};
System.out.print("Массив: ");
for (int i = 0; i < array.length; i++) {
System.out.print(array[i]);
if (i < array.length - 1) {
System.out.print(" ");
}
}
System.out.println();
int positiveCount = 0;
for (int num : array) {
if (num > 0) {
positiveCount++;
}
}
System.out.println("Количество положительных элементов: " + positiveCount);
}
}