我有我的課:c + +繪製矩形位置
class Rectangle : public TwoDim
{
public:
void fun() {};
void printShape();
Rectangle(int x1, int y1, int height1, int width1)
{
x = x1;
y = y1;
height = height1;
width = width1;
}
};
而且功能打印:
void Rectangle::printShape()
{
{
cout << "+";
for (int i = 0; i < width - 2; i++)
{
cout << "-";
}
cout << "+\n";
for (int i = 0; i < height - 2; i++)
{
cout << "|";
for (int j = 0; j < +width - 2; j++)
{
cout << " ";
}
cout << "|\n";
}
cout << "+";
for (int i = 0; i < width - 2; i++)
{
cout << "-";
}
cout << "+\n";
}
}
如何更改我的功能,這樣我會畫從點開始的矩形(x, y)
?
非常感謝
點(x,y)相對於什麼?你的意思是你想添加一些''\ n「'和'」「'字符來改變輸出嗎?或者,如果您想在終端或窗口上找到特定位置,則需要使用特定於操作系統的庫,而不僅僅是核心C++。 – aschepler
聽起來像功課。你有沒有嘗試過?得到了一些我們可以看不到的代碼? – dgnorton
@dgnorton我已經嘗試過,這是一項功課,但我太喜歡這樣做:( – Gan