1

我有我的课:

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)

非常感谢

4

1 回答 1

1

我首先y std::endl在实际打印之前输出 s,然后x " "在有效打印每一行之前输出。

于 2012-12-03T23:18:46.100 回答