Advertisement
Guest User

Untitled

a guest
Dec 16th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. class Trojkat
  6. {
  7. float a,b,c;
  8. float S,p,S1;
  9.  
  10. public:
  11. void przypisz (float bok1, float bok2, float bok3)
  12. {
  13. a=bok1;
  14. b=bok2;
  15. c=bok3;
  16. }
  17. void oblicz()
  18. {
  19. p=(a+b+c)/2;
  20. S1=(p*(p-a)*(p-b)*(p-c));
  21. S=sqrt(S1);
  22. }
  23. void wypisz()
  24. {
  25. cout<<"Bok1: "<<a<<endl;
  26. cout<<"Bok2: "<<b<<endl;
  27. cout<<"Bok3: "<<c<<endl;
  28. cout<<"Pole wynosi: "<<S;
  29. }
  30. } ;
  31. int main()
  32. {
  33. Trojkat tr;
  34. tr.przypisz(3,4,5);
  35. tr.oblicz();
  36. tr.wypisz();
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement