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

I'm Trying to print my square on the middle of the console

为什么我无法在控制台中间绘制正方形? 我需要改变什么? 它只打印第一行,请帮助,谢谢。

#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;
}

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