#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 ответ
Непонятна проблема. Выводите построчно -
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
-
-
В том, что вывод - построчный, значит, границы надо выводить вместе с числами, а не после того, как вы из вывели. Вы не можете вернуться на строку выше и выводить заново (по крайней мере, в стандартном выводе).– Harry9 мая 2020 в 16:16