Click here to Skip to main content
15,889,876 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Simulating movement Pin
Code-o-mat24-Apr-10 22:02
Code-o-mat24-Apr-10 22:02 
GeneralRe: Simulating movement Pin
Software_Developer29-Apr-10 6:26
Software_Developer29-Apr-10 6:26 
AnswerRe: Simulating movement Pin
molesworth29-Apr-10 7:11
molesworth29-Apr-10 7:11 
GeneralRe: Simulating movement Pin
Code-o-mat29-Apr-10 9:16
Code-o-mat29-Apr-10 9:16 
QuestionWhats in a name? Pin
Tadeusz Westawic23-Apr-10 2:01
Tadeusz Westawic23-Apr-10 2:01 
QuestionConsole shapes? Pin
venomation18-Apr-10 2:58
venomation18-Apr-10 2:58 
AnswerRe: Console shapes? Pin
Richard MacCutchan18-Apr-10 11:06
mveRichard MacCutchan18-Apr-10 11:06 
AnswerRe: Console shapes? Pin
MikeMarq20-Apr-10 16:33
MikeMarq20-Apr-10 16:33 
Basically the way to approach this is to draw a rectangle like you did before but put some conditions in to determine if you should print a star or a blank.

First to get the width: Notice that except for the top line the triangle's width increases by 2 for each line it goes down.
Therefore: Width = (Height * 2) - 1

To determine whether to draw a star you need to find if you are close enough to the center of the triangle.
Center = Width / 2

On each line the triangle gets one wider in each direction so you need 2 variables to hold the range where stars should be drawn. So if you use Min and Max as your variable the should initally be set to Center and then subtract 1 from min each line you go down and add 1 to max each line you go down. You can then use these variable to test if your loop counter is between these 2 variables.

Hope this helps,

Mike
Question"Best Fit" Algorithm Request && Teach A Man To Fish Pin
Michael Fritzius17-Apr-10 13:10
professionalMichael Fritzius17-Apr-10 13:10 
AnswerRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
Luc Pattyn17-Apr-10 13:45
sitebuilderLuc Pattyn17-Apr-10 13:45 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
Radhakrishnan G.18-May-10 3:44
Radhakrishnan G.18-May-10 3:44 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
harold aptroot17-Apr-10 14:31
harold aptroot17-Apr-10 14:31 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
Som Shekhar17-Apr-10 20:46
Som Shekhar17-Apr-10 20:46 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
harold aptroot18-Apr-10 2:01
harold aptroot18-Apr-10 2:01 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
Som Shekhar18-Apr-10 2:18
Som Shekhar18-Apr-10 2:18 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish [modified] Pin
harold aptroot18-Apr-10 2:38
harold aptroot18-Apr-10 2:38 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
Som Shekhar18-Apr-10 2:56
Som Shekhar18-Apr-10 2:56 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
harold aptroot18-Apr-10 3:16
harold aptroot18-Apr-10 3:16 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
Som Shekhar18-Apr-10 3:40
Som Shekhar18-Apr-10 3:40 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
harold aptroot18-Apr-10 3:44
harold aptroot18-Apr-10 3:44 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
Som Shekhar18-Apr-10 3:53
Som Shekhar18-Apr-10 3:53 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
Michael Fritzius18-Apr-10 9:40
professionalMichael Fritzius18-Apr-10 9:40 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
Luc Pattyn18-Apr-10 10:02
sitebuilderLuc Pattyn18-Apr-10 10:02 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
Luc Pattyn18-Apr-10 10:07
sitebuilderLuc Pattyn18-Apr-10 10:07 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
harold aptroot18-Apr-10 11:39
harold aptroot18-Apr-10 11:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.