//============================================================== // generowanie liczb pseudolosowych;
//
// ver data temat autor // 100 2005/10/12 Pierwszy projekt J. Malinowski // 101 2007/11/09 Cleanup JM // 102 2019/12/08 Dodanie opisow JM //============================================================== #include <iostream> #include <stdlib.h> #include <time.h> using namespace std; //============================================================== int main(int argc, char *argv[])
{
// Ustawianie ziarna dla generatora; srand(time(0));
// liczba pseudolosowa calkowita; for(int i=0;i<5; i++) {
int x = rand()%6; int y = rand();
// liczba pseudolosowa, zmiennoprzecinkowa, // z rozkladu rownomiernego <0, 1>;
double dy = double(y)/double(RAND_MAX); cout << "rand()%6 = " << x <<endl; cout << "rand()= " << y <<endl;
cout << "<0,1> = " << dy <<endl<<endl; }
cout << "\n\nRAND_MAX= " << RAND_MAX << endl << endl;
system("PAUSE"); return 0;
}