Задание 4 Урок 15. Одномерные массивы
Primary tabs
{15 — 4 Пользователь вводит массив целых чисел из 7 элементов.
Найдите из них два самых больших числа и выведите их на экран.}
var i,max1,max2,temp:integer;
a: array [1..5] of integer;
begin
for i:=low(a) to high(a) do
begin
writeln('Enter the number ',(high(a)-i)+1,' more times');
readln(a[i]);
end;
write('They are now in an array. Look: ');
for i:=low(a) to high(a) do
write(a[i], ' ');
writeln();
for i:=low(a) to high(a) do
begin
if (a[i] > max1) then
begin
temp:= max1;
max1:= a[i];
end;
if (temp > max2) then
max2:=temp;
end;
writeln('The lagest number is: ', max1);
writeln('Previous lagest number is: ', max2);
readln();
end.//Enter the number 5 more times //123 //Enter the number 4 more times //14 //Enter the number 3 more times //-1 //Enter the number 2 more times //66 //Enter the number 1 more times //600 //They are now in an array. Look: 123 14 -1 66 600 //The lagest number is: 600 //Previous lagest number is: 123
- Log in to post comments
- 1483 reads
vedro-compota
Thu, 05/27/2021 - 20:19
Permalink
будет ли это работать, если
будет ли это работать, если ввести все числа как отрицательные?
_____________
матфак вгу и остальная классика =)