How to made a random card output if the card output like this?

     ++++++++ 
     +7    ♥+
     +      +
     +♥    7+
     ++++++++    

so i'm still newbie and i want to made an output card like that with value from As to King and i want to give the output into random card..so when i compile and run,the output can be ♠K or ♣8 or whatever random..it makes me crazy

what can i do to made that card and make it random?

and if there is possible i want to add sorting code to sort the card after random so i will made it 5 card at random, sorting depends to the number and the type..
the sorting of types is like this :
1.Diamond
2.Club
3.Love
4.Spade

can anyone help me?
Last edited on
It's a matter of organization.

The presentation of your card is a string:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const char *const CardPres[] =
{
     "++++++++\n"
     "+7    ♥+\n"
     "+      +\n"
     "+♥    7+\n"
     "++++++++\n",

     "++++++++\n"
     "+8    ♥+\n"
     "+      +\n"
     "+♥    8+\n"
     "++++++++\n",
...
};

A card is a class:
1
2
3
4
5
6
7
8
9
10
11
12
13
class CCard
{
public:
  bool operator<(const CCard &card) const // You need that in order to use std::sort
  {
    return ((m_Type < card.m_Type) && (m_Number < card.m_Number));
  }

public:
  int m_Number;
  int m_Type;
  int m_Pres;
};


Your deck is an array of CCard:
1
2
3
4
5
6
7
8
9
CCard deck[] = { { 0, 0, 0}, { 1, 1, 1}, ...};
const int size_deck = sizeof(deck) / sizeof(*deck);
CCard new_deck[size_deck];
for(int i = 0; i < size_deck; ++i)
{
  int card_idx = rand() % size_deck;
  new_deck[i] = deck[card_idx]
}
std::sort(deck, deck + size_deck);


Fort std::sort look at this:
http://www.cplusplus.com/reference/algorithm/sort/
can you explain it more detail cause i still can't get it..
What is it that you don't get? class? array? What? Be more specific.
Topic archived. No new replies allowed.