Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <cstdlib>
- using namespace std;
- class Wektor
- {
- public:
- float x,y;
- void wczytaj()
- {
- cout<<"podaj x: ";
- cin>>x;
- cout<<"podaj y: ";
- cin>>y;
- }
- double dl()
- {
- return sqrt((x*x)+(y*y));
- }
- void wyswietl()
- {
- cout<<dl();
- }
- };
- Wektor suma (Wektor u, Wektor v)
- {
- Wektor wynik;
- wynik.x=u.x+v.x;
- wynik.y=u.y+v.y;
- return wynik;
- }
- int main()
- {
- Wektor u,v,w;
- u.wczytaj();
- v.wczytaj();
- w=suma(u,v);
- u.wyswietl();
- cout<<" ma dlugusc "<<u.dl()<<endl;
- v.wyswietl();
- cout<<" ma dlugosc "<<v.dl()<<endl;
- u.wyswietl(); cout<<" + "; v.wyswietl(); cout<<" = "; w.wyswietl();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement