1) Const n=10; var a:array[1..n]of integer; i,s:integer; begin for i:=1 to n do begin a[i]:=random(41)-20; write(a[i]:4); if a[i]<0 then s:=s+a[i]; end; writeln; writeln(' S= ',s); end. 2) Const n=20; var i,s:integer; a:array[1..n]of integer; begin for i:=1 to n do begin a[i]:=random(11)+15; write(a[i]:4); if a[i]mod 2=0 then s:=s+a[i]; end; writeln; writeln('S = ',s); end.
Private Sub CommandButton1_Click() Dim s() As Integer, n As Integer, m As Integer Dim i As Integer, j As Integer Dim min As Integer, max As Integer, q As Integer, w As Integer Cells.Clear n = InputBox("CTROKI", , 4) m = InputBox("CTOLBEC", , 5) Randomize ReDim s(n, m) As Integer For i = 1 To n max = -100: min = 100 For j = 1 To m s(i, j) = Int(Rnd() * 60 - 10) Cells(i, j) = s(i, j) Cells(i + 2 + n, j) = s(i, j) If min > s(i, j) Then min = s(i, j) q = j End If If max < s(i, j) Then max = s(i, j) w = j End If Next j Cells(i + 2 + n, w) = min Cells(i + 2 + n, q) = max Next i End Sub
Const
n=10;
var
a:array[1..n]of integer;
i,s:integer;
begin
for i:=1 to n do
begin
a[i]:=random(41)-20;
write(a[i]:4);
if a[i]<0 then
s:=s+a[i];
end;
writeln;
writeln(' S= ',s);
end.
2)
Const
n=20;
var
i,s:integer;
a:array[1..n]of integer;
begin
for i:=1 to n do
begin
a[i]:=random(11)+15;
write(a[i]:4);
if a[i]mod 2=0 then
s:=s+a[i];
end;
writeln;
writeln('S = ',s);
end.
Dim s() As Integer, n As Integer, m As Integer
Dim i As Integer, j As Integer
Dim min As Integer, max As Integer, q As Integer, w As Integer
Cells.Clear
n = InputBox("CTROKI", , 4)
m = InputBox("CTOLBEC", , 5)
Randomize
ReDim s(n, m) As Integer
For i = 1 To n
max = -100: min = 100
For j = 1 To m
s(i, j) = Int(Rnd() * 60 - 10)
Cells(i, j) = s(i, j)
Cells(i + 2 + n, j) = s(i, j)
If min > s(i, j) Then
min = s(i, j)
q = j
End If
If max < s(i, j) Then
max = s(i, j)
w = j
End If
Next j
Cells(i + 2 + n, w) = min
Cells(i + 2 + n, q) = max
Next i
End Sub