3 Replies - 1369 Views - Last Post: 20 October 2011 - 07:21 AM Rate Topic: -----

#1 yangladesh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 20-October 11

Sorting a hand of cards in poker

Posted 20 October 2011 - 01:31 AM

I am working on an assignment that involves creating a simplified poker game. I am new to C++, but this is for class, so I am here to learn. Anyways...

After I deal each players hand vector, how would I sort the vector before it prints? They are char vectors called hand1 for player 1, and hand2 for player 2. The deck vector is a char as well, but the rank array is a string (so that the number 10 prints), and the suit array is a char (so that the actual symbols print). Instead of printing: 8<heart>, 3<club>, A<spade>, 4<spade>, 9 <diamond>, 8<club>, 2<club>, it would print: 2<club>, 3<club>, 4<spade>, 8<heart>, 8<club>, 9 <diamond>, A<spade>.

I hope this was enough information. I can send my code if you'd like to look at it. No pointers, no classes. I'm not at that level yet (unless there is no other way to do what I am asking). I can improve upon this project in my next class.

Is This A Good Question/Topic? 0
  • +

Replies To: Sorting a hand of cards in poker

#2 Salem_c  Icon User is online

  • void main'ers are DOOMED
  • member icon

Reputation: 1574
  • View blog
  • Posts: 2,996
  • Joined: 30-May 10

Re: Sorting a hand of cards in poker

Posted 20 October 2011 - 02:52 AM

http://cboard.cprogr...ards-poker.html

How to choose a forum -> http://www.catb.org/...ions.html#forum
Was This Post Helpful? 0
  • +
  • -

#3 yangladesh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 20-October 11

Re: Sorting a hand of cards in poker

Posted 20 October 2011 - 03:13 AM

View PostSalem_c, on 20 October 2011 - 02:52 AM, said:



Yes, that is me as well. You see, I've been working on this for 3 days now, just the hand sorting, with no luck. So in an act of desperation, I posted to multiple forums to see if I can get an accumulative amount of information that would help me. Did I post to the wrong forum? This is the C/C++ forum, correct?

Regardless, do you have any valuable information for me? :)
Was This Post Helpful? 0
  • +
  • -

#4 WabiSabi  Icon User is offline

  • D.I.C Head

Reputation: 51
  • View blog
  • Posts: 202
  • Joined: 31-December 10

Re: Sorting a hand of cards in poker

Posted 20 October 2011 - 07:21 AM

View Postyangladesh, on 20 October 2011 - 02:31 AM, said:

I am working on an assignment that involves creating a simplified poker game. I am new to C++, but this is for class, so I am here to learn. Anyways...

After I deal each players hand vector, how would I sort the vector before it prints?


Here's one way to sort a vector:
http://www.cplusplus...algorithm/sort/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1