使用箭头符号打印圆圈

Printing a circle using arrow symbols

我一直在努力使用箭头符号和 delay();Sleep(); 绘制一个圆形图案,就像在打印 之后它会延迟大约几秒钟然后打印 等等。这会给人一种 画圈 的印象。像

        ↑

   ←         →

        ↓

我试过到处搜索,到目前为止我发现的是如何只阅读箭头键VM_KEYDOWN documentation。可悲的是,这不是我想要的。请帮忙? Ps。我知道我还没有发布任何 "Productive try" 那是因为我没有所以不要生气 :X 任何帮助将不胜感激。 :)

更新: 我试图用这次失败的尝试打印箭头。

#include <iostream>
#include <string>
int main() { 
    std::wstring s(L"←→↑↓"); 
    std::wcout << s << "\n"; 
}

UPDATED-2* 所以我设法用这个打印符号:

#include <iostream>
using namespace std;
int main()
{
  char left,right,up,down;

  up = 24;
  down = 25;
  left = 27;
  right = 26;

  cout << up;
  cout << down;
  cout << left;
  cout << right;
  cout << "\n";
  system("PAUSE");  
  return 0;
}

但现在我需要知道如何使用上面打印的序列来完成它。

工作尝试

#include <iostream>
#include <iomanip>
#include <windows.h>

using namespace std;
int main()
{
    char left, right, up, down;

    up = 24;
    down = 25;
    left = 27;
    right = 26;
    cout << setw(10);
    cout << up;
    cout << endl;
    cout << setw(20);
    Sleep(1000);
    cout << right;

    cout << endl;
    cout << endl;
    cout << endl;

    cout << setw(10);
    Sleep(1000);
    cout << down;
    Sleep(1000);

    cout << left;

    system("PAUSE");
    return 0;
}

但这显然不是accurate/efficient。

很高兴看到这种努力。我做了一些更改,并添加了一个功能来将光标位置设置到您打印 的同一行。试试这个:

    #include <iostream>
    #include <iomanip>
    #include <windows.h>
    #include <conio.h>
    using namespace std;
    HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD CursorPosition;
    void gotoXY(int, int);

    int main(){
    char left, right, up, down;
    up = 24;
    down = 25;
    left = 27;
    right = 26;
    cout << setw(20) << up<< endl << endl << endl<< setw(25);
    Sleep(1000);
    cout << right << endl<< endl<< endl << setw(20);
    Sleep(1000);
    cout << down;
    Sleep(1000);
    cout << endl;
    gotoXY(0, 2 + (1));
    cout << setw(15) << left<< endl;
    _getch();
    return 0;
   }
    void gotoXY(int x, int y)
    {
        CursorPosition.X = x;
        CursorPosition.Y = y;
        SetConsoleCursorPosition(console, CursorPosition);
    }

I admit it isn't that efficient either but it works and it should help you understand/move forward better.