In my C++ class we have to write a program that makes a hollow triangle that looks like this
. . . . .*
. . . .*.*
. . .*. . .*
. .*. . . . .*
.*. . . . . . .*
***********
#include <iostream>
usingnamespace std;
int main()
{
int base;
int rowCount=0;
int spaceCount=0;
int innerSpace=0;
int lastRow=0;
char symbol;
cout <<"Enter a value to represent the base of a triangle shape (not to exceed 80) ";
cin>>base;
while (!cin || base>80)
{
cout <<"Enter a value to represent the base of a triangle shape (not to exceed 80) ";
cin>>base;
}
if (base%2==0)
base++;
cout<< "Enter the charater to be used to generate the triangle shape ";
cin >> symbol;
while (rowCount< (base/2))
{
spaceCount=rowCount;
while (spaceCount<base/2)
{
cout<<" ";
spaceCount++;
}
cout<<symbol;
innerSpace=rowCount*2-1;
while (innerSpace>=1 && innerSpace<base)
{
cout<<" ";
innerSpace--;
}
if (rowCount>0 &&rowCount<base)
cout<<symbol<<endl;
else
cout<<endl;
rowCount++;
if (rowCount==base/2)
{
lastRow=1;
while (lastRow<=base)
{
cout<<symbol;
lastRow++;
}
}
// else
//return 1;
}
return 0;
}
#include <iostream>
usingnamespace std;
int main()
{
int base=11;
int rowcount=0;
int spacecount=0;
int innerSpace=0;
int firstRow=0;
while (rowcount<=base/2)
{
spacecount=1;
while (spacecount<=rowcount)
{
cout<<".";
spacecount++;
}
cout<<rowcount<<endl;
innerSpace=rowcount;
while (innerSpace<base - rowcount + 1)
{
cout<<".";
innerSpace++;
}
rowcount++;
}
return 0;
}
no that didnt sem to work and not I am trying to manually input the output this is what I am getting right now with what I have and the innerspace commented out
0
.1
..2
...3
....4
.....5
Process returned 0 (0x0) execution time : 0.082 s
Press any key to continue.
I do the numbers are my row count just so I can see where things are and the . so far are the spaces from the right to what ever symbol is picked. I have not figured out how to get the inner spacing and the right side symbol. that is the same way I started the regular triangle.