Quote:
|
Nevermind.
|
Okay take this example. You have 3 numbers: X, Y and Z. (X, Y and Z can be any 3 numbers at random)
How would you go about finding which one is the smallest. Forget about programming for now, just use your common sense logic. |
Well...I would look at it...see which one is the smallest..and say yup, that's the smallest.
I think i'm missing your point? |
What SoccerDude meant is: how to find the smallest number if you can compare only two at the time? (because the "min" function gives you the smaller of two, not three)
So, suppose you have three rocks and a scale such as this one (doesn't show you the weight, only allows to compare two things). How would you proceed to find the lightest one? |
Quote:
so to compare if X is smaller than Y, you would say if(X<Y). So let's go back to our small example. You have 3 numbers hidden from you X, Y and Z. They can contain any number. You can compare two of them at a time, using the if operator like the example above. How do you go about finding the minimum of the 3 numbers. You can only compare two of them together at one point, and their contents is unknown to you before you run the program. |
I dunno? Something like X<Y, X<Z, Y<Z?
|
Quote:
|
God.
|
Quote:
For example: x = 4 y = 5 z = 6 compare x, y // result x, compare it to the next compare x, z // result x, x is the smallest x = 5 y = 4 z = 6 compare x, y // result y compare y, z // result y x = 5 y = 6 z = 4 compare x, y // result x compare x, z // result z For just three you're looking at something like this, in pseudo code: if (x<y) result=x else result=y if (result>z) result=z any more variables and you should be thinking about loops, on the same principle, just keep passing the smallest number to the next in the list, comparing, then passing that along, the number at the end is the smallest. |
That's what I was trying to get to. I wanted Saksquash to think about a little though :shifty:
|
Quote:
|
God, I hate math.
|
Quote:
Peace & Luv, Liz |
The course is web design...as in html...I didn't know i'd be doing java.
|
So... somehow you never expected a web design course to consist of learning web technologies?
Peace & Luv, Liz |
Shut the **** up.
|
Quote:
|
Quote:
Which is one reason why I never bothered getting serious about webmastering even though I enjoy it... trying to figure out most programming concepts (i.e. anything beyond HTML and CSS) gives me a headache. Peace & Luv, Liz |
All times are GMT -8. The time now is 09:34 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Design & Logo Copyright ©1998 - 2017, Adventure Gamers®.
All posts by users and Adventure Gamers staff members are property of their original author and don't necessarily represent the opinion or editorial stance of Adventure Gamers.