Как можно исправить проблему с выводом границ в консоли ( с++ )

#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;

void Draw(){
}


int main() {
    int D[6][6];
    int a,b;
    cout<<"Enter the interval from A to B: ";
    cin>>a>>b;
        const int width=43;
        const int height=6;
    for(int i=0;i<width+1;i++)
    {
        cout<<"#";

    }
    cout<<endl;
    for(int i=0;i<6;++i)
    {
     for(int j=0;j<6;++j)
     {
         D[i][j]=rand()%(b-a)+a;
         cout<<" "<<D[i][j]<< " "<<'\t'<<'\t';

     }
     cout << endl;

    }
    for(int i=0;i<height;i++)
    {
        for(int j=0;j<width;j++){
            if(j==0 || j==width-1)
            {
                cout<<"#";
            }

        cout<<" ";

    }
        cout<<endl;

    }
    for(int i=0;i<width+1;i++)
       {
           cout<<"#";
       }
    cout<<endl;
    cout<<endl;
    return 0;
}

введите сюда описание изображения


Ответы (1 шт):

Автор решения: Harry

Непонятна проблема. Выводите построчно -

const int width=33;
const int height=6;
for(int i=0;i<width+1;i++)
{
    cout<<"#";

}
cout<<endl;
for(int i=0;i<6;++i)
{
    cout << "# ";
    for(int j=0;j<6;++j)
    {
        D[i][j]=rand()%(b-a)+a;
        cout << setw(4) << D[i][j] << " ";
    }
    cout << " #\n";
}
for(int i=0;i<width+1;i++)
{
    cout<<"#";

}

Вот результат: https://ideone.com/WxRtlV

→ Ссылка