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
|
#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 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;
}
|