【问题标题】:How can I see the full 20x70 2d array that I just created? C++如何查看我刚刚创建的完整 20x70 二维数组? C++
【发布时间】:2017-08-02 08:57:19
【问题描述】:

这里是新的。好的,所以在我的项目中,我有一个 20x70 二维阵列,但我无法使用通常的二维阵列打印来看到它。 “全部查看”是指我的控制台太小了。有没有办法打印完整的矩阵并在控制台中看到它?或者是否有任何图书馆可以帮助我像在画布上一样打印它? 编辑:我使用 Codeblocks 作为我的 IDE 并在 Windows 控制台中工作。我在谷歌上搜索了一段时间,但我没有找到这个问题的答案。我只找到了如何打印 10x10 2d 数组的答案。

【问题讨论】:

  • 欢迎来到 Stack Overflow。请花点时间再次阅读The Tour 并参考Help Center 中的材料您可以在这里问什么以及如何问。

标签: c++ matrix printing windows-console


【解决方案1】:

您可以尝试按照here 的描述调整控制台窗口的大小:

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

【讨论】:

  • 是否有任何证据表明 OP 可与 Windows 控制台配合使用?
  • @IgorKleinerman 是的,这个答案对我有用。我喜欢你最后如何将控制台刷新到正常大小,这样我就可以看到不同之处。你用“0x41”和“0x5B”教会了我另一件事。我不知道这些是从 A 到 Z 的地址。我只是希望这篇文章不会被删除,因为我相信很多人都在寻找这个答案,其中一些人不会考虑输入“如何调整控制台大小”。另一种解决方案是在文件中打印,但我没有要求。因为我每次迭代后都需要它,而且控制台更方便。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-05-04
  • 2017-12-03
  • 2017-12-19
  • 1970-01-01
  • 2016-03-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多