uses Crt; const n=20; type Vec=array [1..n] of integer; var A: Vec; i, Sum1, Sum2, Col1, Col2: integer; begin ClrScr; Randomize; Sum1:=0; Sum2:=0; Col1:=0; Col2:=0; WriteLn('Massiv A :'); for i:=1 to n do begin A[i]:=random(100); Write(A[i]: 4); if A[i]<50 then begin Sum1:=Sum1+A[i]; Col1:=Col1+1; end else begin Sum2:=Sum2+A[i]; Col2:=Col2+1; end; end; WriteLn; WriteLn('Sred<50 :', Sum1/Col1:6:2) ; WriteLn('Sred>=50 :', Sum2/Col2:6:2) ; ReadLn; end.
x,y:real;
begin
x:=-1;
while x<=1 do begin
Writeln('x=',x:4:1,', y=',x*x*x:9:6);
x:=x+0.1
end
end.
Результат выполнения программы:
x=-1.0, y=-1.000000
x=-0.9, y=-0.729000
x=-0.8, y=-0.512000
x=-0.7, y=-0.343000
x=-0.6, y=-0.216000
x=-0.5, y=-0.125000
x=-0.4, y=-0.064000
x=-0.3, y=-0.027000
x=-0.2, y=-0.008000
x=-0.1, y=-0.001000
x= 0.0, y= 0.000000
x= 0.1, y= 0.001000
x= 0.2, y= 0.008000
x= 0.3, y= 0.027000
x= 0.4, y= 0.064000
x= 0.5, y= 0.125000
x= 0.6, y= 0.216000
x= 0.7, y= 0.343000
x= 0.8, y= 0.512000
x= 0.9, y= 0.729000
x= 1.0, y= 1.000000
uses Crt;
const n=20;
type Vec=array [1..n] of integer;
var A: Vec;
i, Sum1, Sum2, Col1, Col2: integer;
begin
ClrScr;
Randomize;
Sum1:=0;
Sum2:=0;
Col1:=0;
Col2:=0;
WriteLn('Massiv A :');
for i:=1 to n do
begin
A[i]:=random(100);
Write(A[i]: 4);
if A[i]<50 then
begin
Sum1:=Sum1+A[i];
Col1:=Col1+1;
end else
begin
Sum2:=Sum2+A[i];
Col2:=Col2+1;
end;
end;
WriteLn;
WriteLn('Sred<50 :', Sum1/Col1:6:2) ;
WriteLn('Sred>=50 :', Sum2/Col2:6:2) ;
ReadLn;
end.