Advertisement
Future12

Untitled

Apr 26th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.86 KB | None | 0 0
  1. var B: array [1..8] of integer;
  2.     i: integer;
  3.     max: integer;
  4. begin
  5.  
  6.   writeln('Введите массив:');
  7.   for i:=1 to 8 do  //заполнение массива
  8.       read(B[i]);
  9.  
  10.   writeln('Исходный массив:');  //вывод массива
  11.   for i:=1 to 8 do
  12.       writeln('B[',i,'] = ',B[i]);
  13.      
  14.    max:=1;  //выбираем положительное число, тк оно не подходит по условию
  15.    
  16.    for i:=1 to 8 do
  17.      if  (B[i] < 0) and ((B[i] > max) or (max = 1)) then  //отрицательный + (больше максимума или максимум еще не найден)
  18.         max:=B[i];
  19.    
  20.    
  21.    if max = 1 then
  22.       writeln('Отрицательных нет')
  23.     else
  24.        writeln('Максимум среди отрицательных = ',max);
  25.    
  26.  
  27. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement