Hi to all.
I need help. Quick and easy question. Is it possible to randomize and than delate stream of character pairs(one by one) from the input file? How can I do that?
The input is a stream of character pairs that represent playing cards. For example: 2C, 3H, JH...
What I would like to do is randomize the deck then pick first card in the file and put into new array, and then delate that card from the deck. Then randomize again the deck,take the another first card from the deck, place in the new array, and delating from deck ,and so on untill there will be no more cards in the deck.
Is it possible? If yes how could I do that?
Thank you

there are 26 cards in a deck, so generate a list of 26 unique but random numbers. Then if you have a list of cards, just pick them out in the order of the random numbers previously generated. It would be a lot easier to use an vector or list of 2-char strings instead of putting them into all one string.

To remove the first card just erase the first string in the vector or list, then suffle the strings that remain in the vector.

Hi again
I 've one more question for you. If I would have the input as a stream of characters pairs such as:
2C QD TC AD 6C 3D TD 3H 5H 7H AS JH KH
which form a hand of 13 cards. Display hand in a readable form arranged both by suits and by rank within suitThen evaluate the hand by using the fallowing standard bridge values:
aces count 4
kings count 3
quenns count 2
jacks count 1
voids (no cards in a suit) count 3
singletons(one card in the suit) count 2
doubletons( two cards in the suit) count 1
long suit with more than 5 cards in the suit count 1 for each card over 5 in number

The program should produce output :
CLUBS 10 6 2
DIAMONDS A Q 10 3
HEARTS K J 7 5 3
SPADES A
Points = 16

How can I do that?Any ideas. Thanks a lot

You first need to decide what tools you have to solve the problem. I'd use C++ with classes to represent a Card and a Hand and I'd sort the Cards in a Hand as they are dealt rather than sort the hand after the deal, but it could be done with other languages, other tools, and other algorhythms, depending on your knowledge base and preferences.

Hi
But how is it possible to do in C++. Don't have to write a code just explain it in your words
Thanks

Let suits and face values as defined as enumerated user defined types.

Declare and implement classes to represent cards and hands. Overload the >> operator to allow routine syntax to display value of any given card in the format of 2H, AS, 10D, etc, and to display any given hand with the format as described previously.

If this is your game then declare a deck to be a vector of 52 cards and initialize each card to the appropriate values. Shuffle the deck. Define the top to the deck to be index 51 and when dealing the cards reduce the top by one for each card dealt so the deck doesn't need to be reshuffled with each card dealt. Deal the cards one at a time into the (four) hand(s).

If this is a homework assignment and your input is from a file given to you by your instructor, then open the file with an input stream and parse the string input representing a card into suit and face value. place it a card, and put the card in the (appropriate) hand.

Each hand could have four vectors, one for each suit, or each hand could be a two dimensional array of 4 rows and 13 columns where each row represents a suit. Sort each vector, or each row if you prefer, using the sorting technique of your choice (since there will only be a maximum of 13 cards in a suit to sort any sorting algorhithm such as bubble, insertion, whatever, will probably be adequate).

Search each hand for cards with face values that are awarded points along with evaluation for voids, singletons, long suits, etc and give each hand a value.

Display the hand(s) and the associated value(s).

Thanks a lot lerner you helped me a lot
could i have your e-mail just in case if i would have a question?
Thanks

As a public message board we all learn from each other by keeping communications public. Post questions about your code with appropriate snippets, error codes, etc. If you show effort, I can almost guarantee you'll get help.

Hi to all.
I need help. Quick and easy question. Is it possible to randomize and than delate stream of character pairs(one by one) from the input file? How can I do that?
The input is a stream of character pairs that represent playing cards. For example: 2C, 3H, JH...
What I would like to do is randomize the deck then pick first card in the file and put into new array, and then delate that card from the deck. Then randomize again the deck,take the another first card from the deck, place in the new array, and delating from deck ,and so on untill there will be no more cards in the deck.
Is it possible? If yes how could I do that?
Thank you

Can please post the code, If you are done with the problem............

I am working on some what similar problem for one of my assignment :)

Thanks in advance.........

Can please post the code, If you are done with the problem............

I am working on some what similar problem for one of my assignment :)

Maybe you should read the rest of the thread to learn how the problem was solved rather than asking someone to post their solution to save you the trouble of learning to program.

This article has been dead for over six months. Start a new discussion instead.