Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include <iostream>
- #pragma hdrstop
- using namespace std;
- //---------------------------------------------------------------------------
- class Rectangle1
- {
- public:
- double w; //øèðèíà
- double h; //âûñîòà
- Rectangle1(double _w, double _h)
- {
- w=_w;
- h=_h;
- }
- double S() //ïëîùàäü
- {
- return w*h;
- }
- double P() //ïåðèìåòð
- {
- return 2*w+2*h;
- }
- };
- class Circle1
- {
- public:
- double r; //ðàäèóñ
- Circle1(double _r)
- {
- r=_r;
- }
- double S() //ïëîùàäü
- {
- return 3.1415*r*r;
- }
- double P() //ïåðèìåòð
- {
- return 2*3.1415*r;
- }
- };
- int main(int argc, char* argv[])
- {
- Rectangle1 r;
- cout << "Vvedite w & h: ";
- cin >> r.w >> r.h;
- cout <<"S = " << r.S() << " P = " << r.P() << endl;
- Circle1 c;
- cout << "Vvedite r: ";
- cin >> c.r;
- cout <<"S = " << c.S() << " P = " << c.P()<< endl;
- getchar();
- getchar();
- return 0;
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement