1. 程式人生 > >生成任意範圍內的隨機數

生成任意範圍內的隨機數

srand((unsigned)time(NULL));



unsigned long long Rand(unsigned long long l, unsigned long long r) {
    unsigned long long x = (unsigned long long)rand() * rand() * rand() * rand() * rand();
    return x % (r - l + 1) + l;
}