*****
****
***
**
*
Can someone help me with this ^ pattern above?
I only can do this one below
***
**
*
*****
****
***
**
*
Can someone help me with this ^ pattern above?
I only can do this one below
***
**
*
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.
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;
}
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.