Hey there, im trying just for fun to make a small program that is basically a deck of cards split into 4 randomly. 52 cards, no colors, just 4 suits. Im only 2 weeks into coding for C++ so dont be too harsh please, and im only 16. Now back on track, ive set all the strings, added #include <string> and <iostream> in my .h file. So now that i have my 4 strings set with 13 cards each, string set with my 4 types of cards. I dont know how to set it to randomly pick 4 decks with 13 cards each. With all suits included. Im not looking dead on for the answer, im looking for something that'll lead me on track. Im hear to learn, not for give-aways. Any help would be very appreciated. Thanks! :)
I had a conversation with my friend who is in college now for coding/programming. He said when he was in hs his teacher gave him a assignment like this. The requirements were to make a deck of 52 cards, with the normal 4 suits. Then to be able to run a program that would randomly devide the 52 cards into 4 decks of 13. With random numbers and suits in each deck, if that makes since.
And so I dont have to have them? I #defined deck 52. then added int d = deck. gonna try and branch off with that. Should I define each group (spades, hearts, etc.)?
Basically what im trying to do is up my knowledge. :)
I added a function, and added a thing that makes it random.. still trying how to make it work.. Going to define each suit.
i just cant understand how can you use numbers...how will you differentiate it from numbers of otherdeck????????
my advise is just make an array of 52 characters in which first 13 represent some symbol (say 'H' for heart) next 13 represent some other symbol(say 'S' for spade) and so on.....
now shuffle this array using random_shuffle(&arr[0],&arr[51]);
where arr is the name of the array......
Thats why I marked as solved, because I was like.. Im doing this wrong, let me restart. And started to do what you stated. Then read this, thanks. I almost gave up.. I was like, I did this wrong.. Haha, Highly appreciated. :)
Well, if you don't seed the random function to the time or some other value that changes with each run of your program, then every time you run your program the random function will return the same values in the same order. By seeding it to the time, you change its position in this sequence and then you get different results every time as long as your system time is changing.