#include <iostream>
using namespace std;
class Rect
{
private:
int width;
int height;
public:
void init(int w,int h);
void show();
void set_w(int w);
void set_h(int h);
};
int main()
{
Rect rect;
rect.init(0,0);
int w,h;
cout << "请输入矩形的宽和高:" << endl;
cin >> w >>h;
rect.set_w(w);
rect.set_h(h);
rect.show();
return 0;
}
void Rect::init(int w,int h)
{
width = w;
height = h;
}
void Rect::show()
{
cout << "该矩形的周长为:" << 2*(width+height) << endl;
cout << "该矩形的面积为:" << width*height << endl;
}
void Rect::set_w(int w)
{
width = w;
}
void Rect::set_h(int h)
{
height = h;
}
08-24
1207
11-06