The idea is to print 4 shapes, the first two shapes print fine, and the next two shapes using setw are meant to be the mirrors but still printed bellow as they are.
My understanding was that setw made a kind of text box that started outputting from right to left from the text location specified in the parameters, and it works for other examples I have tried. But for some reason when passed through these for loops it just adds tab spaces of the set amount and prints on the wrong side of the setw location.
#include <conio.h>
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int x = 1;
for (int i = 0; i < 9; i++)
{
for (int i = 1; i <= x; i++)
cout << "*";
x++;
cout << endl;
}
cout << endl;
x = x - 1;
for (int i = 0; i < 9; i++)
{
for (int i = 1; i <= x; i++)
cout << "*";
x--;
cout << endl;
}
cout << endl;
for (int i = 0; i < 9; i++)
{
cout << setw(10);
for (int i = 1; i <= x; i++)
cout << "*";
x++;
cout << endl;
}
cout << endl;
for (int i = 0; i < 9; i++)
{
cout << setw(10);
for (int i = 1; i <= x; i++)
cout << "*";
x--;
cout << endl;
}
_getch();
}