zoi20

Untitled

May 15th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. class Vektor3d {
  7. double x, y, z;
  8. public:
  9. void Postavi(double x, double y, double z) {
  10. Vektor3d::x = x; Vektor3d::y = y; Vektor3d::z = z;
  11. }
  12. void Ocitaj(double &x, double &y, double &z) const {
  13. x = Vektor3d::x; y = Vektor3d::y; z = Vektor3d::z;
  14. }
  15. void Ispisi() const {
  16. std::cout << "{" << x << "," << y << "," << z << "}";
  17. }
  18. double DajX() const { return x; }
  19. double DajY() const { return y; }
  20. double DajZ() const { return z; }
  21. double DajDuzinu() const { return sqrt(x * x + y * y + z * z); }
  22. Vektor3d &PomnoziSaSkalarom(double s) {
  23. x *= s; y *= s; z *= s;
  24. return *this;
  25. }
  26. Vektor3d &SaberiSa(const Vektor3d &v) {
  27. x += v.x; y += v.y; z += v.z;
  28. return *this;
  29. }
  30. friend Vektor3d ZbirVektora(const Vektor3d &v1, const Vektor3d &v2);
  31. };
  32.  
  33.  
  34. int main()
  35. {
  36.     cout << "Hello world!" << endl;
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment