Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #pragma hdrstop
- //---------------------------------------------------------------------------
- #pragma argsused
- #include <iostream.h>
- #include <math.h>
- class Bod{
- private:
- int x; //x-ova souradnice
- int y; //y-ova souradnice
- public:
- Bod(){x=0;y=0;} //konstruktor bez parametru, který inicializuje x-ovou souřadnici na 0 a y-ovou taky na 0.
- Bod(int X, int Y){x=X; y=Y;} //konstruktor, který inicializuje obě složky podle zadaných parametrů
- int Vrat_X(){return x;} //členská funkce pro zjištění hodnoty x
- int Vrat_Y(){return y;} //členská funkce pro zjištění hodnoty y
- void Vypis_Souradnice(){cout << "[" << x << "," << y<<"]";} //členskou funkci pro výpis souřadnic bodu ve tvaru [x,y]
- friend int Vrat_Kvadrant(int x,int y);
- 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.
- return true;
- }
- };
- int main(int argc, char* argv[])
- {
- return 0;
- }
- int Vrat_Kvadrant(x,y){ //členskou funkci, která zjistí a vrátí číslo kvadrantu, ve kterém bod leží
- if(x>0 && y >0)
- return 1;
- if(x<0 && y >0)
- return 2;
- if(x>0 && y<0)
- return 4;
- if(x<0 && y <0)
- return 3;
- }
- //---------------------------------------------------------------------------
Add Comment
Please, Sign In to add comment