Advertisement
Immons

Untitled

Mar 5th, 2014
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5.  
  6. /*
  7.     u*v = u1 * v1 + u2 * v2 + u3 * v3
  8. */
  9.  
  10. class Wektory
  11. {
  12.     public:
  13.     double u1 = 0;
  14.     double v1 = 0;
  15.    
  16.     Wektory(double wektorX, double wektorY, dobuleZ);
  17. };
  18.  
  19. Wektory::Wektory(double wektorX, double wektorY, double wektorZ)
  20. {
  21.     u = wektorX;
  22.     v = wektorY;
  23.          w = wektorZ;
  24. }
  25.  
  26. double operator*(Wektory wek1, Wektory wek2)
  27. {
  28.     return wek1.u1 * wek2.u1 + wek1.v1 * wek2.v1 + wek1.w * wek2.w;
  29. }
  30.  
  31. int main(int argc, char** argv)
  32. {
  33.     double x1;
  34.     double y1;
  35.    
  36.     cout << "Podaj wektor X1:" << endl;
  37.     cin >> x1;
  38.     cout << "Podaj wektor Y1:" << endl;
  39.     cin >> y1;
  40.    
  41.     Wektory wek1(x1, y1);
  42.    
  43.     cout << "Podaj wektor X2:" << endl;
  44.     cin >> x1;
  45.     cout << "Podaj wektor Y2:" << endl;
  46.     cin >> y1;
  47.    
  48.     Wektory wek2(x1, y1);
  49.    
  50.     cout << "Podaj wektor X3:" << endl;
  51.     cin >> x1;
  52.     cout << "Podaj wektor Y3:" << endl;
  53.     cin >> y1;
  54.    
  55.     Wektory wek3(x1, y1);
  56.    
  57.     cout << wek1*wek2;<< endl;
  58.    
  59.     system("pause");
  60.  
  61.    
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement