随机数的产生

 1 #include<cstdio>
 2 #include<ctime>
 3 #include<algorithm>
 4 using namespace std;
 5 int main()
 6 {
 7     srand(unsigned(time(NULL)));
 8     int n = rand() % 50 + 1;
 9     printf ("%d
",n);
10     return 0;
11 }

a+rand()%b    a为区间起始点,b为区间长度

原文地址:https://www.cnblogs.com/hss-521/p/7355904.html