Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Wektory{
- public:
- Wektory(int x=0,int x1=0 ):wektor_x(x),wektor_x1(x1){};
- Wektory operator +(Wektory &wektor1){
- Wektory wektors;
- wektors.wektor_x = wektor_x + wektor1.wektor_x;
- wektors.wektor_x1 = wektor_x1 + wektor1.wektor_x1;
- return wektors;
- }
- Wektory operator -(Wektory wektor_x2){
- Wektory wektors1;
- wektors1.wektor_x = wektor_x - wektor_x2.wektor_x;
- wektors1.wektor_x1 = wektor_x1 - wektor_x2.wektor_x1;
- return wektors1;
- }
- friend istream & operator >>(istream &wejscie ,Wektory &p){
- wejscie >> p.wektor_x >> p.wektor_x1;
- return wejscie;
- }
- friend ostream & operator << (ostream &wyjscie ,Wektory &p){
- wyjscie << p.wektor_x << ' '<< p.wektor_x1;
- return wyjscie;
- }
- private:
- int wektor_x;
- int wektor_x1;
- };
- int main(void){
- Wektory p1,p2,p3,p4;
- cout << "Podaj wartosc x i y wektora"<<endl;
- cin >> p1;
- cout << "Podaj wartosc x i y wektora 2"<<endl;
- cin >>p2;
- p3 = p1 + p2;
- cout << "Wartosc po dodania wartosc wektorow : ";
- cout << p3<<endl;
- p4 = p1 - p2;
- cout << "Wartosc po odjeciu wartosc wektorow : ";
- cout << p4 <<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement