2D Array as a pyramid

I need to get the this array to display as a pyramid. Later on I have to read in a file that's random numbers and and -1's so its not just zeros. I have already set it up to where just the numbers that aren't -1 display. It has to be in a 2D array because this is the first part of a larger project.
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <fstream>
#include <cstdlib>   
#include <iomanip>   
#include <algorithm> 
#include <strstream>
using namespace std;

int main()
{
	const int maxr = 7;
	const int maxc = 7;
	int np[maxr][maxc] = { 0,0,0,0,0,0,0, 
			        -1,0,0,0,0,0,0,
			        -1,-1,0,0,0,0,0,
			        -1,-1,-1,0,0,0,0,
				-1,-1,-1,-1,0,0,0,
				-1,-1,-1,-1,-1,0,0,
				-1,-1,-1,-1,-1,-1,0};  
	int i, j, shift = 3;

	//array skipping the -1
	cout << endl;
	cout << "Starting of the display for the pyramid" << endl;

	for (i = maxr - 1; i >= 0; i--)
	{ 
		cout << endl;
		for (j = 0; j < maxc; j++)
		{
				if (np[i][j] != -1)
				cout << setw(shift) << np[i][j] << " ";
		}
	}
			
	cout << endl;

	system("pause");

	return 0;

}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
The display looks something like this:
0
0 0
0 0 0
0 0 0 0
0 0 0 0 0
0 0 0 0 0 0
I want the display to look like this:
           0
          0 0
         0 0 0
        0 0 0 0
       0 0 0 0 0
      0 0 0 0 0 0
Topic archived. No new replies allowed.