标签:
int Random5() { return rand() % 5 + 1; } int Random7() { return rand() % 7 + 1; } int rand7() { int i; do { i = 5 * (Random5() - 1) + Random5(); } while (i > 21); return i % 7 + 1; } int rand10() { int i; do { i = 7 * (Random7() - 1) + Random7(); } while (i > 40); return i % 10 + 1; }
标签:
原文地址:http://www.cnblogs.com/liuhg/p/rand5.html