here is what i done so far :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#include<iostream>
using namespace std;
void main()
{
int x=0,y,z,f;
cin >> z;
f=z;
while (x<z){
y=0;
while (y < (z-f)/2){ cout << " ";y++;}
while (y<f){ cout << "*";y++;}
cout << endl;
if (x<z/2)
f-=2;
else
f+=2;
if (z%2==0 && x==(z/2-1)) f+=2;
x++;
}
}
|
the shape will be like this
*****
**
**
*****
and i got stuck here and don't know how to fix it !