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

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

procedure Data_to_matrix;

Var key: Char;

    File_Name:string;

Begin

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

  WriteLn('**** 1 - Input data from Keyboard;');

  WriteLn('**** 2 - Input data from File.');

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

    Write('**** Enter number of operation: ');  key:=readkey;

  case Key of

    '1' :  Take_Matrix_From_Keyboard(Matrix, Size);

    '2' :  begin

             Write('Enter name of file: ');  ReadLn(File_Name);

             Take_Matrix_From_File(Matrix, File_Name, Size);

           end;

  end;

End;

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

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

procedure Data_to_Vector;

Var key: Char;

    File_Name:string;

Begin

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

  WriteLn('**** 1 - Input data from Keyboard;');

  WriteLn('**** 2 - Input data from File.');

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

    Write('**** Enter number of operation: ');  key:=readkey;

  case Key of

    '1' :  Take_Vector_From_Keyboard(Vector, Size);

    '2' :  begin

             Write('Enter name of file: '); ReadLn(File_Name);

             Take_Vector_From_File(Vector, File_Name, Size);

           end;

  end;

End;

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

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

END.

Результатывыполненияпрограммы:

****------------------Menu------------------****:

**** 1 - multiplication of vector on scalar;

**** 2 - sum of two vectors;

**** 3 - scalar multiplication of vectors;

**** 4 - multiplication of matrix on the number;

**** 5 - multiplication of matrix on the vector;

**** 6 - sum of two matrices;

**** 7 - subtraction of two matrices;

**** 8 - multiplication of two matrices;

**** 9 - Exit.

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

****----------------------------------------****:

**** Enter number of operation:

1 - multiplication of vector on scalar;

Enter scalar :5

Enter what vector multiply on scalar: {A or B}:A

   [X]= 15             [Y]= 30             [Z]= 40

2 - sum of two vectors;

   [X]=  7             [Y]=  9             [Z]= -1

3 - scalar multiplication of vectors;

Scal_Mul_Vector = -540

4 - multiplication of matrix on the number;

Enter number :6

Enter what matrix multiply on number: {A or B}:A

   Matrix[1,1]= 18     Matrix[1,2]= 24     Matrix[1,3]= 30

   Matrix[2,1]= -6     Matrix[2,2]=  0     Matrix[2,3]= 12

   Matrix[3,1]=-12     Matrix[3,2]= -6     Matrix[3,3]=  0

5 - multiplication of matrix on the vector;

Enter what matrix multiply on vector: {A or B}:B

Enter what vector multiply on matriox: {A or B}:A

   Matrix[1,1]=  0     Matrix[1,2]=  6     Matrix[1,3]=-16

   Matrix[2,1]= -3     Matrix[2,2]=  6     Matrix[2,3]= 16

   Matrix[3,1]=  9     Matrix[3,2]= -6     Matrix[3,3]=  0

6 - sum of two matrices;

   Matrix[1,1]=  3     Matrix[1,2]=  5     Matrix[1,3]=  3

   Matrix[2,1]= -2     Matrix[2,2]=  1     Matrix[2,3]=  4

   Matrix[3,1]=  1     Matrix[3,2]= -2     Matrix[3,3]=  0

7 - subtraction of two matrices;

   Matrix[1,1]=  3     Matrix[1,2]=  3     Matrix[1,3]=  7

   Matrix[2,1]=  0     Matrix[2,2]= -1     Matrix[2,3]=  0

   Matrix[3,1]= -5     Matrix[3,2]=  0     Matrix[3,3]=  0

8 - multiplication of two matrices;

   Matrix[1,1]= 11     Matrix[1,2]=  2     Matrix[1,3]=  2

   Matrix[2,1]=  6     Matrix[2,2]= -3     Matrix[2,3]=  2

   Matrix[3,1]=  1     Matrix[3,2]= -3     Matrix[3,3]=  2

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

   Matrix[1,1]=-12     Matrix[1,2]=  0     Matrix[1,3]= 17

   Matrix[2,1]=-10     Matrix[2,2]=  5     Matrix[2,3]= -8

   Matrix[3,1]=-17     Matrix[3,2]=-19     Matrix[3,3]=-19