Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class wektor
- {
- float mac[3];
- public:
- wektor(float = 1.0, float = 2.0, float = 3.0);
- void wyswietl();
- wektor mnoz(wektor a, wektor b);
- };
- wektor::wektor(float a, float b, float c)
- {
- mac[0] = a;
- mac[1] = b;
- mac[2] = c;
- }
- void wektor::wyswietl()
- {
- cout<<this->mac[0]<<" : ";
- cout<<this->mac[1]<<" : ";
- cout<<this->mac[2]<<" : ";
- }
- wektor wektor::mnoz(wektor a, wektor b)
- {
- wektor zwracany;
- for (int i = 0; i<3 ; i++){
- zwracany.mac[i] = a.mac[i] * b.mac[i];
- }
- return zwracany;
- }
- int main()
- {
- wektor jeden;
- wektor dwa(3.4,2.4,4.3);
- wektor trzy = jeden.mnoz(jeden, dwa);
- trzy.wyswietl();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement