Скалярное произведение векторов. Программа находит скалярное произведение 3-х векторов — Pascal(Паскаль)

uses crt;

const
  n = 6;

Type
  Tmass = array [1 .. 6] of integer;

  { ----------------------------------- }
function Scolar(v1, v2: Tmass): integer;
var
  i, sm: integer;
begin
  sm := 0;
  for i := 1 to n do
    sm := sm + v1[i] * v2[i];
  Scolar := sm;
end;
{ ----------------------------------- }

var
  x, y, z: Tmass;
  i: integer;

begin
  clrscr;
  writeln('Vector X:');
  for i := 1 to n do
  begin
    write('Enter Xi ', i, ': ');
    readln(x[i]);
  end;
  writeln('Vector Y:');
  for i := 1 to 6 do
  begin
    write('Enter Yi ', i, ': ');
    readln(y[i]);
  end;
  writeln('Vector Z:');
  for i := 1 to 6 do
  begin
    write('Enter Zi ', i, ': ');
    readln(z[i]);
  end;
  writeln('XY=', Scolar(x, y));
  writeln('XZ=', Scolar(x, z));
  writeln('YZ=', Scolar(y, z));
  readln;

end.

Leave a Comment