Write a program that produces the following output using nested for loops.
****** ///////////// ******
***** ///////////\\ *****
**** /////////\\\\ ****
*** //////\\\\\\\ ***
** ////\\\\\\\\\ **
* //\\\\\\\\\\\ *
\\\\\\\\\\\\\
#include <iostream>
using namespace std;
int main() {
const int N = 6;
int nStar = N;
int nSlash = 2*N;
int nBackSlash = 0;
for (int i=0; i<=N; i++) {
for (int j=0; j<nStar; j++)
cout << '*';
if (nStar > 0)
cout << ' ';
for (int j=0; j<nSlash; j++)
cout << '/';
for (int j=0; j<nBackSlash; j++)
cout << '\\';
if (nStar > 0)
cout << ' ';
for (int j=0; j<nStar; j++)
cout << '*';
cout << endl;
nStar--;
nSlash -= 2;
nBackSlash += 2;
}
}
Comments
Leave a comment