program Project2; {$APPTYPE CONSOLE} uses SysUtils,windows;
var a,b:array of real; i:byte; cs,sk,da,db:real; n:integer; begin SetConsoleOutputCP(1251); randomize; writeln('Введите n'); readln(n); Setlength(a,n); Setlength(b,n); writeln('Вектор À'); for i:=0 to high(a) do begin a[i]:=-5+10*random; write(a[i]:5:1); end; writeln; writeln('Вектор B'); for i:=0 to High(b) do begin b[i]:=-5+10*random; write(b[i]:5:1); end; writeln; {Скалярные произведения и длинны векторов} sk:=0; da:=0; db:=0; for i:=0 to n-1 do begin sk:=sk+a[i]*b[i]; da:=da+sqr(a[i]); db:=db+sqr(b[i]); end; {Косинус} cs:=sk/sqrt(da)/sqrt(db); write('Cos(aльфа)=',cs:0:3); readln; end.
begin var xc:=300; var yc:=250; var r:=150; var dx:=Trunc(r*cos(Pi/3)); var dy:=Trunc(r*sin(Pi/3)); Polygon((xc+r,yc),(xc+dx,yc-dy),(xc-dx,yc-dy),(xc-r,yc), (xc-dx,yc+dy),(xc+dx,yc+dy)); r:=r-10; dx:=Trunc(r*cos(Pi/3)); dy:=Trunc(r*sin(Pi/3)); Pen.Color:=clRed; Brush.Color:=Pen.Color; Polygon((xc+r,yc),(xc+dx,yc-dy),(xc-dx,yc-dy),(xc-r,yc), (xc-dx,yc+dy),(xc+dx,yc+dy)); Font.Color:=clWhite; Font.Size:=50; Font.Style:=fsBold; SetCoordinateOrigin(xc-90,yc-40); Write('STOP'); end.
program Project2;
{$APPTYPE CONSOLE}
uses
SysUtils,windows;
var a,b:array of real;
i:byte;
cs,sk,da,db:real; n:integer;
begin
SetConsoleOutputCP(1251);
randomize;
writeln('Введите n');
readln(n);
Setlength(a,n);
Setlength(b,n);
writeln('Вектор À');
for i:=0 to high(a) do
begin
a[i]:=-5+10*random;
write(a[i]:5:1);
end;
writeln;
writeln('Вектор B');
for i:=0 to High(b) do
begin
b[i]:=-5+10*random;
write(b[i]:5:1);
end;
writeln;
{Скалярные произведения и длинны векторов}
sk:=0;
da:=0;
db:=0;
for i:=0 to n-1 do
begin
sk:=sk+a[i]*b[i];
da:=da+sqr(a[i]);
db:=db+sqr(b[i]);
end;
{Косинус}
cs:=sk/sqrt(da)/sqrt(db);
write('Cos(aльфа)=',cs:0:3);
readln;
end.
uses GraphABC;
begin
var xc:=300;
var yc:=250;
var r:=150;
var dx:=Trunc(r*cos(Pi/3));
var dy:=Trunc(r*sin(Pi/3));
Polygon((xc+r,yc),(xc+dx,yc-dy),(xc-dx,yc-dy),(xc-r,yc),
(xc-dx,yc+dy),(xc+dx,yc+dy));
r:=r-10;
dx:=Trunc(r*cos(Pi/3));
dy:=Trunc(r*sin(Pi/3));
Pen.Color:=clRed;
Brush.Color:=Pen.Color;
Polygon((xc+r,yc),(xc+dx,yc-dy),(xc-dx,yc-dy),(xc-r,yc),
(xc-dx,yc+dy),(xc+dx,yc+dy));
Font.Color:=clWhite;
Font.Size:=50;
Font.Style:=fsBold;
SetCoordinateOrigin(xc-90,yc-40);
Write('STOP');
end.