Guest User

Untitled

a guest
Aug 16th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.39 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #pragma hdrstop
  4.  
  5. //---------------------------------------------------------------------------
  6.  
  7. #pragma argsused
  8. #include <iostream.h>
  9. #include <math.h>
  10.  
  11. class Bod{
  12.  
  13. private:
  14. int x; //x-ova souradnice
  15. int y; //y-ova souradnice
  16. public:
  17. Bod(){x=0;y=0;} //konstruktor bez parametru, který inicializuje x-ovou souřadnici na 0 a y-ovou taky na 0.
  18. Bod(int X, int Y){x=X; y=Y;} //konstruktor, který inicializuje obě složky podle zadaných parametrů
  19.  
  20. int Vrat_X(){return x;} //členská funkce pro zjištění hodnoty x
  21. int Vrat_Y(){return y;} //členská funkce pro zjištění hodnoty y
  22. void Vypis_Souradnice(){cout << "[" << x << "," << y<<"]";} //členskou funkci pro výpis souřadnic bodu ve tvaru [x,y]
  23. friend int Vrat_Kvadrant(int x,int y);
  24.  
  25. bool operator<(const Bod &c){if( sqrt((c.x*c.x) + (c.y*c.y)) < sqrt(x*x + y*y)) //přetížený operátor < pro porovnání dvou bodů. Větší bude ten, který je dále od začátku souřadnic.
  26. return true;
  27. }
  28. };
  29.  
  30. int main(int argc, char* argv[])
  31. {
  32. return 0;
  33. }
  34.  
  35. int Vrat_Kvadrant(x,y){ //členskou funkci, která zjistí a vrátí číslo kvadrantu, ve kterém bod leží
  36. if(x>0 && y >0)
  37. return 1;
  38. if(x<0 && y >0)
  39. return 2;
  40. if(x>0 && y<0)
  41. return 4;
  42. if(x<0 && y <0)
  43. return 3;
  44. }
  45. //---------------------------------------------------------------------------
Add Comment
Please, Sign In to add comment