Advertisement
dzieciol

cpp5 zadanie 1a

Nov 4th, 2016
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class wektor
  6. {
  7.     float mac[3];
  8. public:
  9.     wektor(float = 1.0, float = 2.0, float = 3.0);
  10.     void wyswietl();
  11.     wektor mnoz(wektor a, wektor b);
  12.  
  13. };
  14.  
  15.  
  16. wektor::wektor(float a, float b, float c)
  17. {
  18.     mac[0] = a;
  19.     mac[1] = b;
  20.     mac[2] = c;
  21. }
  22. void wektor::wyswietl()
  23. {
  24.     cout<<this->mac[0]<<" : ";
  25.     cout<<this->mac[1]<<" : ";
  26.     cout<<this->mac[2]<<" : ";
  27.  
  28.  
  29. }
  30. wektor wektor::mnoz(wektor a, wektor b)
  31. {
  32.     wektor zwracany;
  33.     for (int i = 0; i<3 ; i++){
  34.          zwracany.mac[i] = a.mac[i] * b.mac[i];
  35.     }
  36.  
  37. return zwracany;
  38. }
  39.  
  40.  
  41.  
  42.  
  43. int main()
  44. {
  45.         wektor jeden;
  46.         wektor dwa(3.4,2.4,4.3);
  47.         wektor trzy  = jeden.mnoz(jeden, dwa);
  48.         trzy.wyswietl();
  49.  
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement