Box of numerics

<
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
int number1=5;
int number2=4;
for(int i=1; i<=7; i++)
{
if(rows <= 1)
 for(int i=1; i<=7; i++) 
        {
            cout<< number1;
        }
     else if(i<7)
    {
        cout<< endl;
for(int j=1; j<=6; j++) 
  {
  if(j==1 || j==6)
                cout<< number1;
            else
                cout<< " ";
        }
    }
    else
    {
        cout<< endl;
    for(int k=1; k<=6; k++)
   {
            cout<<number1;
    }
}  

>
my program prints this shape
1
2
3
4
5
6
 555555555
 5       5
 5       5
 5       5
 5       5
 555555555

but I have been trying to make it look like this
1
2
3
4
5
6
7
8
9
 555555555
 544444445
 543333345
 543222345
 543212345
 543222345
 543333345
 544444445
 555555555

I have heard about this website from a friend how much helpful you guys are, I wish you would help me too
Last edited on
Pseudocode:

Set outer to the value that should fill the box border.

FOR row in range 0 to 2*outer-1
    Set row_val to the absolute value of row - (outer-1)
    FOR col in range 0 to 2*outer-1
        Set col_val to the absolute value of col - (outer-1)
        Output the greater of col_val and row_val
    END FOR
    Ouput a newline
END FOR 
Last edited on
Topic archived. No new replies allowed.