I need to write and algorithm on how to sort the deck of cards into piles of the same color. How do I do that?
How do I write this algorithm? I have a standard deck of playing cards.?
One would naturally think that one would examine each card and have a condition on its color. Depending if the color condition was found to be true it would be added to one of four spots.
if (color == red) { add to red pile }
if (color == blue) { add to blue pile }
etc...
Past that, you're question is not posed in a way that makes it easier to answer. Remember to give as much information as you can in your question so a person answering can give the most accurate advice.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment