U E D R , A S I H C RSS

삼총사Cpp Study/숙제1/곽세환

~cpp 
#include <iostream>
using namespace std;

class CRectangle
{
private:
	int width;
	int height;
	
public:
	CRectangle();
	CRectangle(int x, int y);
	int GetWidth();
	int GetHeight();
	int GetBorderLength();
	int GetArea();
	void Draw();
	void SetRect(int x, int y);
	
};

CRectangle::CRectangle()
{
	width = 0;
	height = 0;
}

CRectangle::CRectangle(int x, int y)
{
	width = x;
	height = y;
}

void CRectangle::Draw()
{
	for (int i = 0; i < height; i++)
	{
		for (int j = 0; j < width; j++)
			cout << "*";
		cout << endl;
	}
}

int CRectangle::GetWidth()
{
	return width;
}

int CRectangle::GetHeight()
{
	return height;
}

int CRectangle::GetBorderLength()
{
	return 2 * (width + height);
}

int CRectangle::GetArea()
{
	return width * height;
}

void CRectangle::SetRect(int x, int y)
{
	width = x;
	height = y;
}

int main()
{
	CRectangle rect1(3, 3);
	CRectangle rect2;
	rect2.SetRect(4, 5);
	cout << "rect1의 가로길이 : " << rect1.GetWidth() << endl;
	cout << "rect1의 세로길이 : " << rect1.GetHeight() << endl;
	cout << "rect1의 둘레길이 : " << rect1.GetBorderLength() << endl;
	cout << "rect1의 넓이 : " << rect1.GetArea() << endl;
	rect1.Draw();
	cout << "rect2의 가로길이 : " << rect2.GetWidth() << endl;
	cout << "rect2의 세로길이 : " << rect2.GetHeight() << endl;
	cout << "rect2의 둘레길이 : " << rect2.GetBorderLength() << endl;
	cout << "rect2의 넓이 : " << rect2.GetArea() << endl;
	rect2.Draw();		
	
	return 0;
}


100점입니다. 뭐라고 태클걸것도 하나도 없네요 _ --snowflower


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:39
Processing time 0.0077 sec