I have an assignment where I have to print out a shape like this:

> 
> Let number of rows =9, and char a=x, char b=y and char c=z  
> 
> [output](https://i.stack.imgur.com/ci1bL.png) 
> 
> 
> 

Anyway, I havent been able to accomplish much.
I managed to print two half triangles w/ one of them inverted, but, the output has this [weird line breaks](https://i.stack.imgur.com/ehskC.png). I also cant seem to know how I'm supposed to alternate the letters each time. 
Here's what I managed to do so far.

```
#include <iostream>
using namespace std;

void PrintFigure(int n, char a, char b, char c)
{
    int i,j,k;
    int m=n/2;

// for upper half-triangle

        for(i=0;i<=(n/2);i++)
    {
       for(j=1;j<=i;j++)
       {
    cout<<" ";
       }
       for(k=m-i-1;k>=0;k--)
       {
   cout<<a;
       }
       cout<<endl;
    }

// for the middle line

    for (i=0; i<=m ;i++)
    {
        if (i%2==0) cout<< b; else cout <<c;
    }

// for the lower half-triangle

    for (i=n;i>=1;i--)
    {
        for(j=1;j<i;j++)
        {
            cout << " ";
        }
        for (k=m;k>=i;k--)
        {
            cout <<c;
        }
        cout << endl;
    }
}

int main()
{
    cout<<"Figure1 starts:"<<endl;
    PrintFigure(9, 'x', 'y', 'z');
    cout<<"Figure1 ends:"<<endl;

    cout<<endl;

    cout<<"Figure2 starts:"<<endl;
    PrintFigure(15, '*', '-', '+');
    cout<<"Figure2 ends:"<<endl;

    return 0;
}

```