我正在尝试在控制台中间打印我的方块

问题描述 投票:0回答:1

为什么我不能在控制台中间画我的方块?我需要改变什么?它只打印第一行,请帮助,谢谢。

#include "stdafx.h"
#include "iostream"
#include "conio.h"


 using namespace System;
 using namespace std;


 void DibujaCuadrado()
{
 for (int f=1;f<=5;f++)
   {
    for (int c=1; c<=5;c++)
    {
        cout << "O";
    }
    cout << endl;
  }
}

int main()
{
Console::SetWindowSize(80, 40);
Console::SetCursorPosition(40, 20);
DibujaCuadrado();

_getch();
return 0;
}
visual-c++ c++-cli clr
1个回答
2
投票

您正在使用标准C ++控制台输出以及CLR System :: Console命名空间游标定位。 std::endl将光标位置重置为左侧。您可能希望在每个f-for循环后使用Console::CursorLeft = 40;重置光标位置。

© www.soinside.com 2019 - 2024. All rights reserved.