Re: Drawing diamond shaped pattern with C
assuming you meant 7 for the input:
(7-1)/2 = 3, the number of spaces before the first/last *
each row decreases/increases the lead space by 1
each row increases/decreases the inner spaces by 2 (with 1 center space inserted as well)
So, your spaces are:
3
2,2+1
1,4+1
0,6+1
1,4+1
2,2+1
3
From that, you should be able to build 2 for loops to draw the diamond. Also, you need to be sure the value entered is odd.
|