我如何看到刚刚创建的完整的20x70 2D数组?C

How can I see the full 20x70 2d array that I just created? C++

本文关键字:2D 20x70 数组 创建 何看      更新时间:2023-10-16

新的。好的,所以在我的项目中,我有一个20x70 2D阵列,但是使用通常的2D阵列打印我看不到所有这些。通过"看到一切",我的意思是我的控制台太小了。有什么方法可以打印完整的矩阵并在控制台中看到它?还是有任何可以帮助我像画布中打印它的图书馆?编辑:我正在使用CodeBlocks作为我的IDE,并在Windows控制台中工作。我在Google上搜索了一段时间,但我没有找到这个问题的答案。我只找到了如何打印10x10 2D阵列的答案。

您可以尝试调整控制台窗口的大小:

#include <iostream>
//the following line is necessary for the
//  GetConsoleWindow() function to work!
//it basically says that you are running this
//  program on Windows 2000 or higher
#define _WIN32_WINNT 0x0500
//it is important that the above line be typed
//  BEFORE <windows.h> is included
#include <windows.h>
using namespace std;
int main (void)
{
  HWND console = GetConsoleWindow();
  RECT r;
  GetWindowRect(console, &r); //stores the console's current dimensions
  //MoveWindow(window_handle, x, y, width, height, redraw_window);
  MoveWindow(console, r.left, r.top, 800, 600, TRUE);
  for (int j = 0; j < 100; ++j)
    {
      for (int i = 0x41; i < 0x5B; ++i)
        cout << (char)i;
    }
  cout << endl;
  Sleep(1000);
  MoveWindow(console, r.left, r.top, r.right - r.left, r.bottom - r.top,        TRUE);
}