Program Ulitka; Var SunnyDay: Array [1..30] Of Boolean; a, b, c, i: Integer; Begin WriteLn('a = '); ReadLn(a); WriteLn('b = '); ReadLn(b); b := b * 100; Randomize; For i := 1 To 30 Do Begin If Random(2) = 1 Then SunnyDay[i] := True Else SunnyDay[i] := False; End; For i := 1 To 30 Do Begin If SunnyDay[i] = True Then Begin a := a + 2; If a > b Then a := b; End Else Begin a := a - 1; If a < 0 Then a := 0; End; End; WriteLn('Дни месяца были таковы:'); For i := 1 To 30 Do Begin If SunnyDay[i] = True Then WriteLn(i, '. Солнечный') Else WriteLn(i, '. Пасмурный') End; WriteLn('К концу 30 дня местоположение улитки равно ', a, ' см над землей'); ReadLn; End.
Var SunnyDay: Array [1..30] Of Boolean;
a, b, c, i: Integer;
Begin
WriteLn('a = ');
ReadLn(a);
WriteLn('b = ');
ReadLn(b);
b := b * 100;
Randomize;
For i := 1 To 30 Do
Begin
If Random(2) = 1 Then
SunnyDay[i] := True
Else
SunnyDay[i] := False;
End;
For i := 1 To 30 Do
Begin
If SunnyDay[i] = True Then
Begin
a := a + 2;
If a > b Then
a := b;
End
Else
Begin
a := a - 1;
If a < 0 Then
a := 0;
End;
End;
WriteLn('Дни месяца были таковы:');
For i := 1 To 30 Do Begin
If SunnyDay[i] = True Then
WriteLn(i, '. Солнечный')
Else
WriteLn(i, '. Пасмурный')
End;
WriteLn('К концу 30 дня местоположение улитки равно ', a, ' см над землей');
ReadLn;
End.
program test;
var
n, m: integer;
max: integer;
count: integer;
number: integer;
i: integer;
function GetDividersCount(number: integer): integer;
var
limit: integer;
count: integer;
i: integer;
begin
limit := number div 2;
count := 0;
for i := 1 to limit do
if number mod i = 0 then
count := count + 1;
result := count;
end;
begin
write('Enter range: ');
read(n, m);
max := 0;
for i := n to m do
begin
count := GetDividersCount(i);
if max < count then
begin
max := count;
number := i;
end;
end;
writeln('Result: ', number);
end.