Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class prostokat{
- private:
- double a;
- double b;
- friend void pole(prostokat p);
- friend void obwod(prostokat p);
- public:
- prostokat(double a_,double b_);
- };
- prostokat::prostokat(double a_,double b_){
- a=a_;
- b=b_;
- }
- void pole(prostokat p){
- cout << p.a*p.b << endl;
- }
- void obwod(prostokat p){
- cout << p.a*2+p.b*2 << endl;
- }
- class trojkat{
- private:
- double a;
- double b;
- double c;
- double h;
- friend void pole(trojkat p);
- friend void obwod(trojkat p);
- public:
- trojkat(double a_,double b_, double c_, double h_);
- };
- trojkat::trojkat(double a_,double b_, double c_, double h_){
- if(a<b+c){
- cout<< "to nie trojkat";
- }
- else if(b<c+a){
- cout<< "to nie trojkat";
- }
- else if(c<b+a){
- cout<< "to nie trojkat";
- }
- else{
- a=a_;
- b=b_;
- c=c_;
- h=h_;
- }
- }
- void pole(trojkat p){
- cout << (p.h*p.a)/2<< endl;
- }
- void obwod(trojkat p){
- cout <<a+b+c << endl;
- }
- int main()
- {
- prostokat p1(10,2);
- pole(p1);
- cout << "Hello world!" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement