1) begin var m:=ArrRandom(ReadInteger('n='),-45,90); m.Println; var (a,b):=ReadInteger2('a,b='); m:=m.Where(t->t mod 7<>0).Where(t->not(t.InRange(a,b))).ToArray; m.Println; end.
2) begin var m:=ArrRandom(ReadInteger('n='),-45,90); m.Println; var k:=ReadInteger('k='); var i:=0; while i<>m.Length-1 do begin if (m[i]<0) and (m[i+1]<0) or (m[i]>0) and (m[i+1]>0) then begin SetLength(m,m.Length+1); for var j:=m.Length-2 downto i+1 do m[j+1]:=m[j]; m[i+1]:=k; i+=1; end; i+=1; end; m.Println; end.
DIM m AS INTEGER, n AS INTEGER CLS INPUT "M,N = ", m, n REDIM a(1 TO m, 1 TO n) AS INTEGER RANDOMIZE TIMER FOR i = 1 TO m FOR j = 1 TO n a(i, j) = 100 * RND - 50 PRINT USING ""; a(i, j); NEXT j PRINT NEXT i min = 1000: max = -1000 FOR i = 1 TO m FOR j = 1 TO n IF a(i, j) > max THEN max = a(i, j) jmax = j END IF IF a(i, j) < min THEN min = a(i, j) jmin = j END IF NEXT j NEXT i DIM p AS DOUBLE p = 1 FOR i = 1 TO m p = p * a(i, jmax) * a(i, jmin) NEXT i PRINT "P="; p
//Версия 3.3, сборка 1611 (06.01.2018)
1)
begin
var m:=ArrRandom(ReadInteger('n='),-45,90); m.Println;
var (a,b):=ReadInteger2('a,b=');
m:=m.Where(t->t mod 7<>0).Where(t->not(t.InRange(a,b))).ToArray; m.Println;
end.
Пример:
n= 10
18 54 30 -38 39 16 -40 68 2 -36
a,b= 18 30
54 -38 39 16 -40 68 2 -36
2)
begin
var m:=ArrRandom(ReadInteger('n='),-45,90); m.Println;
var k:=ReadInteger('k=');
var i:=0;
while i<>m.Length-1 do
begin
if (m[i]<0) and (m[i+1]<0) or (m[i]>0) and (m[i+1]>0)
then begin
SetLength(m,m.Length+1);
for var j:=m.Length-2 downto i+1 do m[j+1]:=m[j];
m[i+1]:=k;
i+=1;
end;
i+=1;
end;
m.Println;
end.
Пример:
n= 10
25 89 -4 5 85 30 37 -3 13 -3
k= 0
25 0 89 -4 5 0 85 0 30 0 37 -3 13 -3
DIM m AS INTEGER, n AS INTEGER
CLS
INPUT "M,N = ", m, n
REDIM a(1 TO m, 1 TO n) AS INTEGER
RANDOMIZE TIMER
FOR i = 1 TO m
FOR j = 1 TO n
a(i, j) = 100 * RND - 50
PRINT USING ""; a(i, j);
NEXT j
PRINT
NEXT i
min = 1000: max = -1000
FOR i = 1 TO m
FOR j = 1 TO n
IF a(i, j) > max THEN
max = a(i, j)
jmax = j
END IF
IF a(i, j) < min THEN
min = a(i, j)
jmin = j
END IF
NEXT j
NEXT i
DIM p AS DOUBLE
p = 1
FOR i = 1 TO m
p = p * a(i, jmax) * a(i, jmin)
NEXT i
PRINT "P="; p
Пример
M,N = 4,7
11 42 -35 -8 -11 -40 -23
-16 -45 -41 13 0 -41 22
32 48 29 -10 15 -38 22
27 -22 -23 -9 7 2 30
P= 3983377305600