C++随机数生成
#include<boost/algorithm/string.hpp>
#include <string>
#include <ctime>
#include <boost/lexical_cast.hpp>
using namespace boost;
using namespace std;
void main()
{
srand(time(0));
int tem;
for (int i = 0; i < 10; ++i)
{
tem = 100 + rand() % ( 100 + 1);
cout << tem << " " ;
}
int wait;
cin >> wait;
}
#include<boost/algorithm/string.hpp>
#include <string>
#include <ctime>
#include <boost/lexical_cast.hpp>
int RandBetween(int a, int b)
{
int result;
result = a + rand() % ( b - a + 1);
return result;
}
using namespace boost;
using namespace std;
void main()
{
srand(time(0));
for (int i = 0; i < 25; ++i)
{
cout << RandBetween(1000, 5000) << " " ;
}
int wait;
cin >> wait;
}