ex3_4.c

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 31 行

C
31
字号
//
// Copyright (C) 1991 Texas Instruments Incorporated.
//
// Permission is granted to any individual or institution to use, copy, modify,
// and distribute this software, provided that this complete copyright and
// permission notice is maintained, intact, in all copies and supporting
// documentation.
//
// Texas Instruments Incorporated provides this software "as is" without
// express or implied warranty.
//

#include <cool/Random.h>                        // Include Random number class
#include <iostream.h>

int main (void) {
    cout << __FILE__ << endl;

  CoolRandom r1 (SIMPLE, 1, 3.0, 9.0);          // Simple rand() generator
  CoolRandom r2 (THREE_CONGRUENTIAL, 1, 5.0, 11.5);     // Highly random generator

  cout << "Simple random number generator:\n";  // Output banner title 
  int i;
  for (i = 0; i < 10; i++)                      // Generate 10 random numbers
    cout << "  Random number " << i << " is: " << r1.next () << "\n";
  cout << "\nThree congruential linear random number generator:\n"; // Banner
  for (i = 0; i < 10; i++)                      // Generate 10 random numbers
    cout << "  Random number " << i << " is: " << r2.next () << "\n";
  return (0);                                   // Exit with OK status
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?