#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <limits>

int roll(int mini, int maxi)
{
    int v = maxi - mini;
    int x  = mini + (rand() % (v+1));
    return x;

}

void flush_stream(std::istream& stream)
{
    stream.clear();
    stream.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}

int get_valid_number(const std::string& prompt)
{
    int number = 0;

    bool valid = false;
    while (!valid)
    {
        std::cout << prompt << std::endl;
        if (std::cin >> number)
        {
            valid = true;
        }
        flush_stream(std::cin);
    }

    return number;
}

void caller()
{
    const int a = get_valid_number("Enter minimum number");
    int b = std::numeric_limits<int>::min();
    do
    {
        b = get_valid_number("Enter maximum number");
    }
    while (b <= a);
    const int c = get_valid_number("How many rolls?");

    for (int i = 0; i < c; ++i)
    {
        std::cout << roll(a, b) << std::endl;
    }
}

int main()
{
    srand(time(NULL));
    caller();
}
