Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- class punkty
- {
- float x,y;
- public:
- punkty(float x1, float y1)
- {
- x=x1;
- y=y1;
- }
- void wektor()
- {
- cout << "Wspolrzedne wektora to (" << x << "; " << y << ")" <<endl;
- }
- float odleglosc()
- {
- float odl;
- odl = sqrt(x*x + y*y);
- return odl;
- }
- void czyOX()
- {
- if(y == 0) cout << "Punkt należy do osi OX" << endl;
- else cout << "Punkt nie należy do osi OX" << endl;
- }
- void czyOY()
- {
- if(x == 0) cout << "Punkt należy do osi OY" << endl;
- else cout << "Punkt nie należy do osi OY" << endl;
- }
- int cwiartka()
- {
- if(x>0 and y>0) return 1;
- if(x<0 and y>0) return 2;
- if(x<0 and y<0) return 3;
- if(x>0 and y<0) return 4;
- if(x==0 and y==0) return 0;
- }
- };
- int main()
- {
- punkty A(10,20);
- A.wektor();
- cout << "odleglosc miedzy punktami jest rowna " << A.odleglosc() << endl;
- A.czyOX();
- A.czyOY();
- cout << "punky lezy w cwiartce nr: " << A.cwiartka() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement