View Single Post
  #5 (permalink)  
Old 05-12-2008, 12:07 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 2,035
Last Blog:
NaNoWriMo Day 23 The...
Rep Power: 24
WingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the rough
Default 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.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Reply With Quote

Sponsored Links