Const m=4; n=15; var i,j,j0: integer; a:array[1..m,1..n] of integer; jExit,iExit:Boolean; begin Randomize; for i:=1 to m do begin writeln; for j:=1 to n do begin a[i,j]:=random(2); write(a[i,j]:2) end end; writeln; j:=0; jExit:=false; repeat j:=j+1; i:=1; iExit:=false; if a[i,j]=0 then begin repeat i:=i+1; if a[i,j]<>0 then iExit:=true until iExit or (i=m); if i=m then jExit:=true end until jExit or (j=n); if a[i,j]=0 then writeln('Нулевой столбец ',j) else writeln('Нет нулевых столбцов'); end.
var
i,j,j0: integer;
a:array[1..m,1..n] of integer;
jExit,iExit:Boolean;
begin
Randomize;
for i:=1 to m do begin
writeln;
for j:=1 to n do begin
a[i,j]:=random(2);
write(a[i,j]:2)
end
end;
writeln;
j:=0; jExit:=false;
repeat
j:=j+1; i:=1; iExit:=false;
if a[i,j]=0 then begin
repeat
i:=i+1;
if a[i,j]<>0 then iExit:=true
until iExit or (i=m);
if i=m then jExit:=true
end
until jExit or (j=n);
if a[i,j]=0 then writeln('Нулевой столбец ',j)
else writeln('Нет нулевых столбцов');
end.
Тестовый пример:
0 1 1 1 1 0 1 0 1 0 0 0 0 0 1
0 0 1 0 1 0 0 0 1 1 0 0 0 0 0
1 1 0 0 0 1 0 1 1 1 1 1 0 1 1
1 1 1 0 1 0 1 0 0 1 0 1 0 1 0
Нулевой столбец 13
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;
}
}