Isosceles Triange

I need help on making an isosceles triangle 2sides with 5 asterisks, and a base with 9 asterisks, and has no asterisks inside the triangle.

I've come up with the codes on a 2sides with 5 asterisks and the base with 9 asterisks, but this time, it has asterisks inside the triangle.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<iostream.h>

int main()
{ int a, b, c = 5, d=0;
  


   for(a=1;a<=c;a++)

   { 
	   for(b=1;b<=c*2-1;b++)
    
		   if (b<=c+d&&b>=c-d)
   
			   cout<<"*";
   
		   else 
	
			   cout<<" ";
   
			   cout<<"\n";
  
		       d++;
   
   
   }
	return 0;
  }


And it turns out to be like this

    *
   *** 
  *****
 *******
*********



What i need is the triangle to look like this:

    *
   * *
  *   *
 *     *
*********


Anyone can help me supply the codes for the isosceles triangle with no asterisks inside the triangle?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>

using namespace std;

int main()
{
    int a, b, c = 9, d=0;

    for (a=1; a<=c; a++)
    {
        for (b=1; b<=c*2-1; b++)
            if (b==c+d || b==c-d || d==c-1)
                cout<<"*";
            else cout<<" ";
        cout<<"\n";
        d++;
    }
    return 0;
}
        *
       * *
      *   *
     *     *
    *       *
   *         *
  *           *
 *             *
*****************
Topic archived. No new replies allowed.