Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2349615
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:05:52

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) |
给主人留下些什么吧!~~