# Программирование векторных и матричных операций, страница 5

var

File_On_Disk:text;

i:integer;

begin

assign(File_On_Disk,File_Name);

reset(File_On_Disk);

for i:=1 to Size do

close(File_On_Disk);

end;

{===============================================================}

{Считывает вектор с клавиатуры}

procedure Take_Vector_From_Keyboard;

var i:integer;

Orta: ARRAY [1..3] of Char;

begin

Orta[1]:='X';  Orta[2]:='Y';  Orta[3]:='Z';

ClrScr;

for i:=1 to 3 do

Begin

GoToXY(i*20-16,4);

end;

end;

{===============================================================}

{Выводит вектор на экран}

procedure Print_Vector_ON_Screen;

var

i:integer;

Orta: ARRAY [1..3] of Char;

begin

Orta[1]:='X';  Orta[2]:='Y';  Orta[3]:='Z';

ClrScr;

for i:=1 to 3 do

begin

GoToXY(i*20-16,4);

Write('[',Orta[i],']=',Vector[i]:3);  {Вывод строки}

end;

end;

{===============================================================}

{Скалярное произведение векторов}

function Scal_Mul_Vector;

var

Resalt_First,Resalt_Second: Integer;

i:byte;

begin

Resalt_First  := First_Vector[i];

Resalt_Second := Second_Vector[1];

For i:=1 to Size-1 do

Resalt_First:=Resalt_First*First_Vector[i+1];

For i:=1 to Size-1 do

Resalt_Second:=Resalt_Second*Second_Vector[i+1];

Scal_Mul_Vector:=Resalt_First+Resalt_Second;

end;

{===============================================================}

{Суммирует два вектора}

var  i,j:integer;

begin

for i:=1 to Size do

for j:=1 to Size do

Vector_Of_Resalt[i] := First_Vector[i] + Second_Vector[i];

end;

{===============================================================}

{Умножает вектор на скаляр}

procedure Mul_Vector_On_Scal;

var

i:integer;

begin

for i:=1 to Size do

Vector_Of_Resalt[i] := Vector[i] * Scalar;

end;

{===============================================================}

{Выводит вектор в файл}

procedure Print_Vector_To_File;

var

File_On_Disk:text;  i:integer;

begin

assign(File_On_Disk,File_Name);

rewrite(File_On_Disk);

for i:=1 to Size do

write(File_On_Disk,Vector[i],'      ');

close(File_On_Disk);

end;

{===============================================================}

{Конец модуля}

END.

Текстмодуля (U_PutDat):

UNIT U_putDat;

{****--------*****--------****}

INTERFACE {Объявление раздела модуля: INTERFACE - ИНТЕРФЕЙС}

{****--------*****--------****}

{Объявление записи числа}

uses crt, U_Matrix, U_Vector;

procedure Data_to_matrix(var Matrix: MatrixArray; Size: integer);

procedure Data_to_Vector(var Vector: VectorArray; Size: integer);

{****------****------****}

IMPLEMENTATION {Объявление раздела модуля: IMPLEMENTATION - РЕАЛИЗАЦИЯ}

{****------****------****}

{===============================================================}

{Вводит меню}

Begin

ClrScr;

WriteLn('**** 1 - multiplication of vector on scalar;');

WriteLn('**** 2 - sum of two vectors;');

WriteLn('**** 3 - scalar multiplication of vectors;');

WriteLn('**** 4 - multiplication of matrix on the number;');

WriteLn('**** 5 - multiplication of matrix on the vector;');

WriteLn('**** 6 - sum of two matrices;');

WriteLn('**** 7 - subtraction of two matrices;');

WriteLn('**** 8 - multiplication of two matrices;');

WriteLn('**** 9 - Exit.');

WriteLn('**** * - To do function (A-B)(A+B)-2AB.');

WriteLn('****----------------------------------------****:');