Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int u1,u2,u3,v1,v2,v3,uvi,uvj,uvk;
  8.     float suma;
  9.     cout<<"Podaj wspolrzedne pierwszego wektora: "<<endl;
  10.     cin>>u1>>u2>>u3;
  11.     cout<<"Podaj wspolrzedne drugiego wektora: "<<endl;
  12.     cin>>v1>>v2>>v3;
  13.  
  14.     uvi = u2 * v3 - v2 * u3;
  15.     uvj = v1 * u3 - u1 * v3;
  16.     uvk = u1 * v2 - v1 * u2;
  17. suma= sqrt(uvi*uvj*uvk);
  18.  
  19. cout<<"Iloczyn wektorowy to: "<<suma<<endl;
  20.    float vectorA[3], vectorB[3], scalar=0.0;
  21.  
  22.  
  23.    cout << "Podaj wspolrzedne pierwszego wektora: " << endl;
  24.    for(int i=0;i<3;i++)
  25.    {
  26.       cin >> vectorA[i];
  27.    }
  28.    cout << "Podaj wspolrzedne drugiego wektora: " << endl;
  29.    for(int i=0;i<3;i++)
  30.    {
  31.       cin >> vectorB[i];
  32.    }
  33.  
  34.    for(int i=0;i<3;i++)
  35.    {
  36.       scalar = scalar + (vectorA[i] * vectorB[i]);
  37.    }
  38.  
  39.  
  40.    cout << "Iloczyn skalarny to: " << scalar << endl;
  41.  
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement