标签:srand signed rand unsigned and turn algorithm blog null
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",n); 10 return 0; 11 }
a+rand()%b a为区间起始点,b为区间长度
标签:srand signed rand unsigned and turn algorithm blog null
原文地址:http://www.cnblogs.com/hss-521/p/7355904.html