Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <cstdlib>
  4. using namespace std;
  5. class Wektor
  6. {
  7. public:
  8. float x,y;
  9. void wczytaj()
  10. {
  11. cout<<"podaj x: ";
  12. cin>>x;
  13. cout<<"podaj y: ";
  14. cin>>y;
  15.  
  16. }
  17. double dl()
  18. {
  19. return sqrt((x*x)+(y*y));
  20. }
  21. void wyswietl()
  22.  
  23. {
  24. cout<<dl();
  25.  
  26. }
  27. };
  28.  
  29. Wektor suma (Wektor u, Wektor v)
  30. {
  31. Wektor wynik;
  32. wynik.x=u.x+v.x;
  33. wynik.y=u.y+v.y;
  34.  
  35. return wynik;
  36.  
  37. }
  38.  
  39. int main()
  40. {
  41. Wektor u,v,w;
  42. u.wczytaj();
  43. v.wczytaj();
  44. w=suma(u,v);
  45. u.wyswietl();
  46. cout<<" ma dlugusc "<<u.dl()<<endl;
  47. v.wyswietl();
  48. cout<<" ma dlugosc "<<v.dl()<<endl;
  49. u.wyswietl(); cout<<" + "; v.wyswietl(); cout<<" = "; w.wyswietl();
  50.  
  51. return 0;
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement