mardi 24 octobre 2017

how can I draw shape using stars

i am trying a shapes but there are some deficiencies. i want the block at the end. I could not adjust the space and stars at the end block.

If I put the stars at the end, i cant do location of the stars

Can you help me please ?

Picture that i want the shape

#include <iostream>
using namespace std;

int main()
{

int stars=1;
int enter=7;
int space;
space=enter-1;
int smallstar=3;



    for(int k=1;k<enter;k++)
    {
        for(int j=1;j<=1;j++)
        {
            cout<<"*";
        }
        for(int i=1;i<=space;i++)
        {
            cout<<" ";
        } 
        for(int l=1;l<=stars;l++)
        {
            cout<<"*";
        }
        for(int i=1;i<space;i++)
        {
            cout<<" ";
        } 
        for(int i=1;i<space;i++)
        {
            cout<<" ";
        } 
        for(int l=1;l<=stars;l++)
        {
            cout<<"*";
        }
            for(int i=1;i<=2;i++)
        {

            cout<<" ";
        }

        for(int a=1;a<=smallstar;a++)
        {
            cout<<"*";

        }

        smallstar-=2;
        stars+=2;
        space--;
        cout<<endl;


    }



}

Aucun commentaire:

Enregistrer un commentaire