М
Молодежь
К
Компьютеры-и-электроника
Д
Дом-и-сад
С
Стиль-и-уход-за-собой
П
Праздники-и-традиции
Т
Транспорт
П
Путешествия
С
Семейная-жизнь
Ф
Философия-и-религия
Б
Без категории
М
Мир-работы
Х
Хобби-и-рукоделие
И
Искусство-и-развлечения
В
Взаимоотношения
З
Здоровье
К
Кулинария-и-гостеприимство
Ф
Финансы-и-бизнес
П
Питомцы-и-животные
О
Образование
О
Образование-и-коммуникации
Vilgam
Vilgam
15.06.2021 18:50 •  Информатика

Сократите эту программу : ну там мб действия нахождения максимума одной процедурой хз крч program zelda; uses crt; const z=100; varu1,u2,u3: array[1..z]of integer; i,max1,max2,max3: integer; procedure ch1; var n,i,max1,max2,max3: integer; beginn: =7; for i: =1 to n dou1[i]: =random(100); for i: =1 to n dowriteln('элементы массива: ',u1[i]); max1: =u1[i]; max2: =u1[i]; max3: =u1[i]; for i: =1 to n doif u1[i]> max1 then beginmax1: =u1[i]; end; for i: =1 to n doif (u1[i]> max2) and (u1[i]< > max1) then beginmax2: =u1[i]; end; for i: =1 to n doif (u1[i]> max3) and (u1[i]< > max1) and (u1[i]< > max2) then beginmax3: =u1[i]; end; writeln('max1: ',max1,' max2: ',max2,' max3: ',max3); end; procedure ch2; var n,i,ind,max1,max2,max3: integer; beginn: =13; for i: =1 to n dou2[i]: =random(100); for i: =1 to n dowriteln('элементы массива: ',u2[i]); ind: =0; max1: =u2[i]; max2: =u2[i]; max3: =u2[i]; for i: =1 to n doif u2[i]> max1 then beginmax1: =u2[i]; end; for i: =1 to n doif (u2[i]> max2) and (u2[i]< > max1) then beginmax2: =u2[i]; end; for i: =1 to n doif (u2[i]> max3) and (u2[i]< > max1) and (u2[i]< > max2) then beginmax3: =u2[i]; end; writeln('max1: ',max1,' max2: ',max2,' max3: ',max3); end; procedure ch3; var n,i,max1,max2,max3: integer; beginn: =17; for i: =1 to n dou3[i]: =random(100); for i: =1 to n dowriteln('элементы массива: ',u3[i]); max1: =u3[i]; max2: =u3[i]; max3: =u3[i]; for i: =1 to n doif u3[i]> max1 then beginmax1: =u3[i]; end; for i: =1 to n doif (u3[i]> max2) and (u3[i]< > max1) then beginmax2: =u3[i]; end; for i: =1 to n doif (u3[i]> max3) and (u3[i]< > max1) and (u3[i]< > max2) then beginmax3: =u3[i]; end; writeln('max1: ',max1,' max2: ',max2,' max3: ',max3); end; beginch1; ch2; ch3; end.

👇
Ответ:

Так пойдёт?

Объяснение:

program Zeldaproj1;

{$mode objfpc}{$H+}

uses

{$IFDEF UNIX}{$IFDEF UseCThreads}

 cthreads,

 {$ENDIF}{$ENDIF}

 Classes

 { you can add units after this };

const z=100;

type mas=array[1..z] of integer;

var

 u1:mas;

 max1,max2,max3:integer;

procedure ch1(n:integer);

var i:integer;

begin

for i:=1 to n do

u1[i]:=random(100);

for i:=1 to n do

writeln('Элементы массива: ',u1[i]);

max1:=u1[i];max2:=u1[i];max3:=u1[i];

for i:=1 to n do

if u1[i]>max1 then begin

max1:=u1[i];

end;

for i:=1 to n do

if (u1[i]>max2) and (u1[i]<>max1) then begin

max2:=u1[i];

end;

writeln('max1: ',max1,' max2: ',max2,' max3: ',max3);

end;

begin

ch1(5);

readln;

ch1(7);

readln;

ch1(13);

readln;

end.

4,7(89 оценок)
Открыть все ответы
Ответ:
ино7
ино7
15.06.2021
Procedure GetAB(x: integer; var a: integer; var b: integer);
begin
    a := 0;
    b := 1;
    while x > 0 do
    begin
        a := a + 1;
        b := b * (x mod 100);
        x := x div 100;
    end;
end;

var
    x, a, b: integer;

begin
    for x := 10000 to 2000000000 do
    begin
        GetAB(x, a, b);
        if (a = 3) and (b = 18) then
            Println(a, b, x);
    end;
end.

выдает такие значения
3 18 10118
3 18 10209
3 18 10306
3 18 10603
3 18 10902
3 18 11801
3 18 20109
3 18 20303
3 18 20901
3 18 30106
3 18 30203
3 18 30302
3 18 30601
3 18 60103
3 18 60301
3 18 90102
3 18 90201
3 18 180101

Выделенное наибольшее
4,5(24 оценок)
Ответ:
Boi11
Boi11
15.06.2021
Const n=10; 
var a:array[1..n] of integer;
i,s,min:integer;
begin
writeln('Исходный массив:');
for i:=1 to n do
 begin
 a[i]:=random(21)-10;
 write(a[i]:4);
 end;
writeln;
s:=0; 
min:=a[1];
for i:=1 to n do
 begin
 if a[i]>0 then s:=s+a[i];
 if a[i]<min then min:=a[i];
 end;
writeln('s = ',s,'   min = ',min);
for i:=1 to n do
 if a[i]>0 then a[i]:=s
  else if a[i]<0 then a[i]:=a[i]-min;
writeln('Измененный массив:');
for i:=1 to n do  write(a[i]:4);
writeln;
end.

Пример:
Исходный массив:
   9  -3  -5   7   1   5  -6   9  -8   7
s = 38   min = -8
Измененный массив:
  38   5   3  38  38  38   2  38   0  38
4,8(14 оценок)
Это интересно:
Новые ответы от MOGZ: Информатика
logo
Вход Регистрация
Что ты хочешь узнать?
Спроси Mozg
Открыть лучший ответ