katekn6032
?>

C++ Exercise 3. In a one-dimensional array find the number of all positive elements of the array. Exercise 4. In a one-dimensional array find the smallest element (minimum Exercise 5. In a one-dimensional array find the greatest element (maximum). Exercise 6. Write a C++ program that will prompt the user to input ten integer values. (Elements of one-dimensional array). Then find the sum of all positive elements of the array.

Информатика

Ответы

museumuzl

const N = 30;

var a : array[1..N] of integer;

   i, j, x : integer;

   

Begin

 for i := 1 to N do readln(a[i]);

 readln(x);

 for i := 1 to N do begin  //перебираем элементы массива

   if a[i] = x then begin  //если находим элемент равный Х то

     writeln('наименьший номер элемента равного X - ', i); //выводим сообщение

     exit;  //и завершаем программу не завершив перебор, т.к. нам нужен только наименьший номер

   end;

 end;

 writeln('такого элемента нет'); //если перебрав весь массив не находим совпадений то выводим сообщение

end.

Объяснение:

объяснения в комментариях программы

проверено на PascalABC

Ответить на вопрос

Поделитесь своими знаниями, ответьте на вопрос:

C++ Exercise 3. In a one-dimensional array find the number of all positive elements of the array. Exercise 4. In a one-dimensional array find the smallest element (minimum Exercise 5. In a one-dimensional array find the greatest element (maximum). Exercise 6. Write a C++ program that will prompt the user to input ten integer values. (Elements of one-dimensional array). Then find the sum of all positive elements of the array.
Ваше имя (никнейм)*
Email*
Комментарий*

Популярные вопросы в разделе

alena
ella440
Николаев
makeeva-nataliya60
lazareva
mariyachervonnaya44
ckati
Можарова14
oldprince840
motor2218
proplenkusale88
sargisyan
Елена Ирина
Вадимовна
vladexi