Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- class Trojkat
- {
- float a,b,c;
- float S,p,S1;
- public:
- void przypisz (float bok1, float bok2, float bok3)
- {
- a=bok1;
- b=bok2;
- c=bok3;
- }
- void oblicz()
- {
- p=(a+b+c)/2;
- S1=(p*(p-a)*(p-b)*(p-c));
- S=sqrt(S1);
- }
- void wypisz()
- {
- cout<<"Bok1: "<<a<<endl;
- cout<<"Bok2: "<<b<<endl;
- cout<<"Bok3: "<<c<<endl;
- cout<<"Pole wynosi: "<<S;
- }
- } ;
- int main()
- {
- Trojkat tr;
- tr.przypisz(3,4,5);
- tr.oblicz();
- tr.wypisz();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement