Advertisement
Semior001

Pilschikov 11.21

Nov 15th, 2016
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.00 KB | None | 0 0
  1. const
  2.     n = 30;
  3.     INF = -10000000;
  4. type
  5.     vector = array[1..30] of real;
  6. var
  7.     x,y,z: vector;
  8.     i: integer;
  9.     xmin, ymin, zmin, res: real;
  10. function min(a:real; b:real): real;
  11. begin
  12.     if b < a then
  13.         min := b
  14.     else
  15.         min := a;
  16. end;
  17. function multi(a: vector; b:vector): real;
  18. var
  19.     i: integer;
  20.     sum: real;
  21. begin
  22.     for i:=1 to n do
  23.         sum:=sum + a[i] * b[i];
  24.     multi:=sum;
  25. end;
  26. begin
  27.     // ввод вектора x
  28.     for i := 1 to n do
  29.         read(x[i]);
  30.     // ввод вектора y
  31.     for i := 1 to n do
  32.         read(y[i]);
  33.     // ввод вектора z
  34.     for i := 1 to n do
  35.         read(z[i]);
  36.  
  37.     xmin:= INF;
  38.     ymin:= INF;
  39.     zmin:= INF;
  40.  
  41.     // ищем минимум
  42.     for i := 1 to n do
  43.     begin  
  44.         xmin := min(xmin, x[i]);
  45.         ymin := min(ymin, y[i]);
  46.         zmin := min(zmin, z[i]);
  47.     end;
  48.  
  49.     if (ymin>xmin) and (ymin>zmin) then
  50.         res := multi(y,y) - multi(x,z)
  51.     else if (xmin>ymin) and (xmin>zmin) then
  52.         res := multi(x,x) - multi(y,z)
  53.     else
  54.         res := multi(z,z) - multi(x,y);
  55.  
  56.     writeln('Result: ', res);
  57.  
  58. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement