I need to create a program that shows an inverted and right-justified triangle of asterisks. The amount of rows is determined by a positive value entered by the user.
I can get the triangle to work, but it is left justified. I am having trouble with the spacing to get it to be right justified. Hints and help would be great! Here is my code:
#include <iostream>
using namespace std;
int main()
{
int value, starcount = 0, rowcount = 0;
cout<<"Enter a positive integer: ";
cin>> value;
while (value <= 0)
{
cout<<"That was not a positive integer, re-enter: ";
cin>> value;
}
cout<<endl;
cout<<' '; /*If this is taken out, the triangle looks perfect, accept its left justified*/
starcount = rowcount +1;
rowcount = rowcount + 1;
Remember that there is no "empty space" on the screen; there are space characters to the left of your "justified asterisks". I find it often helps to draw what I want to see on the screen using a piece of graph paper, and observe any patterns that may suggest themselves.