using std::srand
这句把分号加上
rand_max改为RAND_MAX
C++是区分大小写的
cout << "three random integer from 0 to " << rand_max <<": "
<< rend() << " " <这句输出句子中,有一个rand写成了read了。
下面是我改了的:
//program 2.5 using random integers
#include
#include
#include
using std::cout;
using std::endl;
using std::rand;
using std::srand;
using std::ctime;
int main() {
const int limit1 = 500; //upper limit for on set of random values
const int limit2 = 31; //upper limlt for another set of values
cout << "first we will use the default sequence form rand(). \n ";
cout << "three random integer from 0 to " << RAND_MAX << ": "
<< rand() << " " << rand() << " " << rand() << endl;
cout << endl << "now we will use a new seed for rand ().\n";
rand((unsigned int)time(0));
cout << "three random integer from 0 to " << RAND_MAX <<": "
<< rand() << " " < return 0;
}
--------------------next---------------------
阅读(1206) | 评论(0) | 转发(0) |