Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- # include <cmath>
- using namespace std;
- class Punkt
- {
- double x;
- double y;
- public:
- Punkt (double xx, double yy);
- Punkt();
- Punkt (Punkt & p);
- double zwroc_x();
- double zwroc_y();
- void ustaw_x(double xx);
- void ustaw_y(double yy);
- double odleglosc_od_punktu(Punkt & p);
- double odleglosc_od_0();
- void przesun_o_wektor(double xxx,double yyy);
- int lezy_w_cwiartce();
- bool jest_symetryczny_wzgl_0(Punkt &p);
- void wyswietl();
- double pobierz();
- };
- Punkt::Punkt (double xx, double yy)
- {
- x=xx;
- y=yy;
- }
- Punkt::Punkt()
- {
- x=0;
- y=0;
- }
- Punkt::Punkt (Punkt & p)
- {
- x=p.x;
- y=p.y;
- }
- double Punkt::zwroc_x()
- {
- return x;
- }
- double Punkt::zwroc_y()
- {
- return y;
- }
- void Punkt::ustaw_x(double xx)
- {
- x=xx;
- }
- void Punkt::ustaw_y(double yy)
- {
- y=yy;
- }
- double Punkt:: odleglosc_od_punktu(Punkt &p)
- {
- return sqrt((p.x-x)*(p.x-x)+(p.y-y)*(p.y-y));
- }
- double Punkt::odleglosc_od_0()
- {
- return sqrt(x*x+y*y);
- }
- void Punkt::przesun_o_wektor(double xxx,double yyy)
- {
- x+=xxx;
- y+=yyy;
- }
- int Punkt::lezy_w_cwiartce()
- {
- if(x>0 and y>0)
- {
- return 1;
- }
- else if (x<0 and y>0)
- {
- return 2;
- }
- else if (x<0 and y<0)
- {
- return 3;
- }
- else if(x==0 or y==0)
- {
- return 0;
- }
- else
- {
- return 4;
- }
- }
- bool Punkt::jest_symetryczny_wzgl_0(Punkt &p)
- {
- if (x==-1*p.x and y==-1*p.y)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- void Punkt::wyswietl()
- {
- cout<<"("<<x<<","<<y<<")"<<endl;
- }
- double Punkt::pobierz()
- {
- cout << "Podaj x:"<<endl;
- cin >> x;
- cout << "Podaj y:"<<endl;
- cin >> y;
- return x,y;
- }
- int main()
- {
- Punkt x1(-1,1);
- Punkt x2(11,6);
- Punkt x3 (-11,-6);
- Punkt x4;
- Punkt x5 (-1,2);
- cout << x1.odleglosc_od_punktu(x2) << endl;
- cout << x5.odleglosc_od_0() << endl;
- x1.przesun_o_wektor(4,6);
- cout << x1.zwroc_x() << " " << x1.zwroc_y() << endl;
- cout << x2.lezy_w_cwiartce() << endl;
- cout << x2.jest_symetryczny_wzgl_0(x3) << endl;
- x2.wyswietl();
- x4.wyswietl();
- x4.pobierz();
- x4.wyswietl();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement