0
*****
 ****
  ***
   **
    *

Can someone help me with this ^ pattern above?
I only can do this one below

***
**
* 
4
Contributors
3
Replies
44
Views
2 Years
Discussion Span
Last Post by Maritimo
0

Create two numbers. Call the first one number_of_spaces. Call the second one number_of_stars.

Set number_of_spaces to zero. Set number_of_stars to five.

Now output number_of_spaces spaces, and number_of_stars stars.
Add one to number_of_spaces, subtract one from number_of_stars.
Repeat previous two instructions until you're done.

Welcome to programming. Programming is thinking. When you get it working, see if you can think of a better algorithm.

Edited by Moschops

-2

it's code

//main

int i , j , lp , PutCout;

lp = PutCout = 3;<-- change num 1,2,3,4,5 ... more ^^

bool PutCheck = false;

for( i = lp ; i > 0 ; i-- ){

    for( j = lp; j > 0; j-- ){

        if( j / ( PutCout + 1 )  == 0 ){
            PutCheck = true;
        }else{
            PutCheck = false;
        }
        cout << ( ( PutCheck == true ) ? "*":" ");
    }

    PutCout--;

    cout << endl;
}
0

Consider you have a counter (c) that goes from 1 to 5.
The number of stars you what to print is s = 6-c.
In this way,
when c values 1 s values 5,
when c values 2 s values 4,
when c values 3 s values 3,
and so on.
That's all you need.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.