How to do this T.T Help me guys ASAP
____*
__***
*****
__***
____*
Half diamond?
1 2 3 4 5 6
|
only this.
*
***
*****
***
*
|
#include<iostream>
using namespace std;
main()
{
int j, i ;
for (int i = 1; i < 3; i++)
{
for (int j = 1; j < 2 * i; j++)
cout<<"*";
cout<<endl;
}
for ( i=3;i>0;i--)
{
for (j=2*i; j>1;j--)
{
cout<<"*";
}
cout<<endl; }
}
Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include<iostream>
using namespace std;
main()
{
int j, i ;
for (int i = 1; i < 3; i++)
{
for (int j = 1; j < 2 * i; j++)
cout<<"*";
cout<<endl;
}
for ( i=3;i>0;i--)
{
for (j=2*i; j>1;j--)
{
cout<<"*";
}
cout<<endl; }
}
|
It looks to me like it's working OK. The output is the same as you have shown.
Last edited on
sorry. The spaces are adjusted. this
_____*
___***
_*****
___***
_____*
So, we can see that each line has a total of 6 characters - n *'s and 6-n spaces.
Does that help?
Don't double post. We don't do homework.