need a bit of help here for a class exercise:
I've been tasked with writing C++ code to get a pyramid that, when run, will create a set pyramid of X's and 0's in specific spots. As of now, I have a pyramid of just X's, but cannot figure out how to get the 0's where I want them. Any help on this would be greatly appreciated.
This is what I'm supposed to get when run:
X
X X
X 0 X
X 0 0 X
X X X X X
This is what I have thus far:
#include <iostream>
using namespace std;
int main()
{
int i, j;
for (i = 0; i < 5; ++i)
{
for (j = 0; j <= i; ++j)
cout << " X ";
cout << endl;
}
return 0;
}