Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <math.h>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. class Vector
  9. {
  10. private:
  11.     float Ox1;
  12.     float Oy1;
  13.     float Ox2;
  14.     float Oy2;
  15.  
  16. public:    
  17.        
  18.     Vector(float new_Ox1, float new_Oy1, float new_Ox2, float new_Oy2)
  19. {
  20. Ox1=new_Ox1;
  21. Oy1=new_Oy1;
  22. Ox2=new_Ox2;
  23. Oy2=new_Oy2;
  24. }
  25.  
  26. void EnterVector1()
  27. {
  28.     cout<<"Please, enter X"<<endl;
  29.     cin>>Ox1;
  30.     cout<<"Please, enter Y"<<endl;
  31.     cin>>Oy1;
  32. }
  33.  
  34. void EnterVector2()
  35. {
  36.     cout<<"Please, enter X"<<endl;
  37.     cin>>Ox2;
  38.     cout<<"Please, enter Y"<<endl;
  39.     cin>>Oy2;
  40. }
  41. void ShowVector1()
  42. {
  43.     cout<<"(";
  44.     cout<<Ox1;
  45.     cout<<";";
  46.     cout<<Oy1;
  47.     cout<<")"<<endl;
  48.  
  49. }
  50. void ShowVector2()
  51. {
  52.     cout<<"(";
  53.     cout<<Ox2;
  54.     cout<<";";
  55.     cout<<Oy2;
  56.     cout<<")"<<endl;
  57.  
  58. }
  59. void LenghtVector()
  60. {
  61.     double a;
  62.  
  63.     a=sqrt(pow(Ox1,2)+pow(Oy1,2));
  64.     cout<<"Lenght of the vector="<<a<<endl;
  65. }
  66.  
  67. void SummaVector()
  68. {
  69.     double a, b;
  70.  
  71.     a=Ox1+Ox2;
  72.     b=Oy1+Oy2;
  73.  
  74.     cout<<"SumV";
  75.     cout<<"(";
  76.     cout<<a;
  77.     cout<<";";
  78.     cout<<b;
  79.     cout<<")"<<endl;
  80. }
  81.  
  82. void ProSVector()
  83. {
  84.     double a, b, c;
  85.    
  86.     a=Ox1*Ox2;
  87.     b=Oy1*Oy2;
  88.     c= a+b;
  89.     cout<<"ProSV"<<c<<endl;
  90. }
  91.  void ProVVector()
  92.  {
  93.      double a, b;
  94.    
  95.     a=Ox1*Ox2;
  96.     b=Oy1*Oy2;
  97.     cout<<"ProVV";
  98.     cout<<"(";
  99.     cout<<a;
  100.     cout<<";";
  101.     cout<<b;
  102.     cout<<")"<<endl;
  103.     }
  104.  
  105.  
  106. };
  107.  
  108.  
  109. int main()
  110. {
  111.     Vector vector (10, 10, 11, 11);
  112.  
  113.  
  114.  
  115.     vector.EnterVector1();
  116.     vector.ShowVector1();
  117.     vector.LenghtVector();
  118.     vector.EnterVector2();
  119.     vector.ShowVector2();
  120.     vector.SummaVector();
  121.     vector.ProSVector();
  122.     vector.ProVVector();
  123.    
  124.     return 0;
  125.     getch();
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement