2017-03-12 37 views
-3

新的在這裏。好吧,在我的項目中,我有一個20x70的二維數組,但我無法使用通常的二維數組打印來看這一切。通過「看到這一切」我的意思是我的控制檯太小了。有沒有辦法打印整個矩陣並在控制檯中看到它?或者是否有任何圖書館可以幫助我像在畫布上一樣印刷它? 編輯:我使用Codeblocks作爲我的IDE並在Windows控制檯中工作。我搜索了一段時間的谷歌,我沒有找到這個問題的答案。我發現只有如何打印10x10 2d陣列的答案。如何查看我剛創建的完整20x70 2d數組? C++

+0

歡迎堆棧溢出。請花時間再次閱讀[The Tour](http://stackoverflow.com/tour),並參閱[Help Center](http://stackoverflow.com/help/asking)中的內容以瞭解您可以在這裏問。 –

回答

-2

你可以嘗試調整控制檯窗口中描述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); 
} 
+1

有沒有任何證據表明OP與Windows控制檯一起工作? –

+0

我想,接受的答案就是足夠的證據。 –

+0

@IgorKleinerman是的,這個答案爲我做了。我喜歡你如何刷新控制檯到最後的正常尺寸,所以我可以看到它們的差異。你教了我另外一個有「0x41」和「0x5B」的東西。我不知道這些是從A到Z的地址。我只是希望這篇文章不會被刪除,因爲我確信很多人都在搜索這個答案,其中一些人不會考慮輸入「如何調整控制檯大小「。另一個解決方案可以打印在一個文件中,但我沒有要求。因爲每次迭代之後我都需要它,並且控制檯更方便。 –