There is probably a really simple solution to this, but I just can't figure it out. I have created a patter of asterisks that is generated by this code:
#include <iostream>
using namespace std;
int main()
{
int i, j;
for (i = 0; i<=10; i++)
{
for (j = 0; j<i; j++)
cout << "*";
cout << "\n";
}
cout << "\n\n";
for (j = 10; j>0; j--)
{
for (i = 0; i<j; i++)
cout << "*";
cout << "\n";
}
cout << "\n";
for (j = 10; j>0; j--)
{
for (i = 0; i<j; i++)
cout << "*";
cout << "\n";
}
cout << "\n";
for (i = 0; i<=10; i++)
{
for (j = 0; j<i; j++)
cout << "*";
cout << "\n";
}
return 0;
}
As you can see the code generates four blocks of asterisk patterns. My issue is that I need the last two blocks to look like this:
**********
*********
********
*******
******
*****
****
***
**
*
*
**
***
****
*****
******
*******
********
*********
**********
I am thinking I need another for-loop inside these two that will make each line begin with an appropriate number of blank spaces, but I am stuck trying to formulate this. Any advice would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire