#include <iostream>
using namespace std;
class Rect
{
private:
int width;
int height;
public:
void init(int w,int h);
int set_w(int w);
int set_h(int h);
void show();
};
void Rect::init(int w,int h)
{
this->width=w;
this->height=h;
}
int Rect::set_w(int w)
{
this->width=w;
}
int Rect::set_h(int h)
{
this->height=h;
}
void Rect::show()
{
int zc=(width*2)+(height*2);
int mj=width*height;
cout << "周长= " << zc << endl;
cout << "面积= " << mj << endl;
}
int main()
{
Rect s1;
s1.init(4,5);
s1.set_w(6);
s1.set_h(6);
s1.show();
return 0;
}
2024.8.29
最新推荐文章于 2024-09-03 18:14:55 发布