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 43 44 45
|
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <vector>
#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}; //array num, 20 elements
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 = maxc - 1; j >= 0; j--)
{
if (np[i][j] != -1)
cout << setw(shift) << np[i][j] << " ";
}
}
cout << endl;
system("pause");
return 0;
}
|