#include <iostream>
#include <cstdlib> 
#include <cstdio>
#include <string>

int color_of_card(int i)
{
    return i / 13;
}

int value_of_card(int i)
{
    return i % 13;
}

std::string card_as_string(int i)
{
    static const std::string facevalues[] = {
        "Two", "Three", "Four", "Five", "Six", "Seven",
        "Eight", "Nine", "Ten", "Jack", "Queen", "King", "Ace"
    };
    static const std::string suits[] = { "Diamonds", "Hearts", "Spades", "Clubs" };

    return facevalues[value_of_card(i)] + " of " + suits[color_of_card(i)];
}

int getcard() {
    return rand() % 52;
}

int main() {
    const int times = 1000;

    int counter = 0;
    for (int y = 0; y != times; y++) {
        const auto card1 = getcard();
        auto card2 = getcard();
        while (card1 == card2) { card2 = getcard(); } // Ensure cards differ.

        if (value_of_card(card1) == value_of_card(card2)) {
            ++counter;
        }
    }
    std::cout << counter << std::endl;  // 58 or 59 normally
    // Once you took a card, there are only 3 card on same value
    // and there is 51 remaining cards.
    std::cout << 3 / 51.f << std::endl; // 0.0588235
}
