View Code of Problem 53

#include<iostream>
#include<malloc.h>
#include<algorithm>
#include<cstring>
using namespace std;

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<n-i;j++)
        {
            cout<<" ";
        }

        for(int j=0;j<2*i-1;j++)
        {
            cout<<"*";
        }
        cout<<endl;
    }

    for(int i=1;i<n;i++)
    {
        for(int j=0;j<i;j++)
        {
            cout<<" ";
        }

        for(int j=0;j<2*n-1-2*i;j++)
        {
            cout<<"*";
        }
        cout<<endl;
    }


    return 0;
}

Double click to view unformatted code.


Back to problem 53