Const CSize1=7; CSize2=6; CSize3=5; type TMas1=array[1..CSize1,1..CSize1] of integer; TMas2=array[1..Csize2, 1..CSize2] of integer; TMas3=array[1..Csize3, 1..CSize3] of integer;
var A1:TMas1; A2:TMas2; A3:TMas3; i,j,x, y:byte;
function zero(i:integer):boolean; begin zero:=false; if i=0 then zero:=true; end;
function interval(i:integer):boolean; begin interval:=false; if (i<=12) and (i>=1) then interval:=true; end;
begin X:=0; Y:=0; randomize; for i:=1 to CSize1 do begin for j:=1 to CSize1 do begin A1[i, j]:=random(50); write(A1[i, j]:3); if zero(A1[i, j]) then inc(x); if interval(A1[i,j]) then inc(y); end; writeln; end; writeln('Kol-vo 0 =', x); writeln('Kol-vo v intervale=', y); writeln; x:=0; y:=0; for i:=1 to CSize2 do begin for j:=1 to CSize2 do begin A2[i, j]:=random(50); write(A2[i,j]:3); if zero(A1[i,j]) then inc(x); if interval(A2[i,j]) then inc(y); end; writeln; end; writeln('Kol-vo 0 =', x); writeln('Kol-vo v intervale=', y); writeln; x:=0; y:=0; for i:=1 to CSize3 do begin for j:=1 to CSize3 do begin A3[i, j]:=random(50); write(A3[i,j]:3); if zero(A3[i,j]) then inc(x); if interval(A3[i,j]) then inc(y); end; writeln; end; writeln('Kol-vo 0 =', x); writeln('Kol-vo v intervale=', y); writeln; x:=0; y:=0; end.
using System;
class Program
{
static void Main()
{
int x1 = 2, y1 = 1;
int x2 = 6, y2 = 5;
int x3 = 10, y3 = 1;
var a = Distance(x2, y2, x3, y3);
var b = Distance(x1, y1, x3, y3);
var c = Distance(x2, y2, x1, y1);
Console.WriteLine("S = {0}", Square(a, b, c));
Console.ReadKey();
}
//растояние между точками
static double Distance(int x1, int y1, int x2, int y2)
{
return Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}
//формула герона
static double Square(double a, double b, double c)
{
var p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
// теорема косинусов
static double Angle(double a, double b, double c)
{
return Math.Acos((b * b + c * c - a * a) / (2 * b * c));
}
static bool IsAcuteAngel(double alpha)
{
return alpha < Math.PI / 2;
}
}
CSize2=6;
CSize3=5;
type TMas1=array[1..CSize1,1..CSize1] of integer;
TMas2=array[1..Csize2, 1..CSize2] of integer;
TMas3=array[1..Csize3, 1..CSize3] of integer;
var A1:TMas1;
A2:TMas2;
A3:TMas3;
i,j,x, y:byte;
function zero(i:integer):boolean;
begin
zero:=false;
if i=0 then zero:=true;
end;
function interval(i:integer):boolean;
begin
interval:=false;
if (i<=12) and (i>=1) then interval:=true;
end;
begin
X:=0;
Y:=0;
randomize;
for i:=1 to CSize1 do
begin
for j:=1 to CSize1 do
begin
A1[i, j]:=random(50);
write(A1[i, j]:3);
if zero(A1[i, j]) then inc(x);
if interval(A1[i,j]) then inc(y);
end;
writeln;
end;
writeln('Kol-vo 0 =', x);
writeln('Kol-vo v intervale=', y);
writeln;
x:=0;
y:=0;
for i:=1 to CSize2 do
begin
for j:=1 to CSize2 do
begin
A2[i, j]:=random(50);
write(A2[i,j]:3);
if zero(A1[i,j]) then inc(x);
if interval(A2[i,j]) then inc(y);
end;
writeln;
end;
writeln('Kol-vo 0 =', x);
writeln('Kol-vo v intervale=', y);
writeln;
x:=0;
y:=0;
for i:=1 to CSize3 do
begin
for j:=1 to CSize3 do
begin
A3[i, j]:=random(50);
write(A3[i,j]:3);
if zero(A3[i,j]) then inc(x);
if interval(A3[i,j]) then inc(y);
end;
writeln;
end;
writeln('Kol-vo 0 =', x);
writeln('Kol-vo v intervale=', y);
writeln;
x:=0;
y:=0;
end.