Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <vector>
- using namespace std;
- vector<unsigned int> wektor;
- vector<bool> wektor2;
- unsigned int random1(unsigned int xn, unsigned int a, unsigned int c, unsigned int M)
- {
- float tmp;
- unsigned int liczba;
- tmp = a*wektor[xn]+c;
- liczba = (unsigned int)tmp%M;
- wektor.push_back(liczba);
- return liczba;
- }
- void random2(int i)
- {
- bool tmp = (wektor2[i-3] + wektor2[i-7]) % 2;
- wektor2.push_back(tmp);
- }
- int main()
- {
- unsigned int generowana;
- unsigned int x0 = 15;
- unsigned int a = 69069;
- int c = 1;
- unsigned int M = 4294967295;
- int przedzialy[] = {0,0,0,0,0,0,0,0,0,0};
- int przedzialy2[] = {0,0,0,0,0,0,0,0,0,0};
- wektor.push_back(15);
- wektor2.push_back(0);
- wektor2.push_back(1);
- wektor2.push_back(1);
- wektor2.push_back(1);
- wektor2.push_back(0);
- wektor2.push_back(1);
- wektor2.push_back(1);
- for(int i = 0; i < 100000; i++)
- {
- unsigned int randomowa1 = random1(i,a,c,M);
- przedzialy[randomowa1/(M/10)]++;
- }
- for(int i = 0; i < 10; i++)
- {
- cout << przedzialy[i] << "\n";
- }
- cout << "Druga czesc\n";
- for(int i = 7; i < 100032; i++)
- {
- random2(i);
- }
- for(int i = 0; i < 100000; i++)
- {
- unsigned int randomowa2 = 0;
- for(float j = 0; j < 32; j++)
- {
- randomowa2 += (wektor2[i+j] * pow(2,j));
- }
- przedzialy2[randomowa2/(M/10)]++;
- }
- for(int i = 0; i < 10; i++)
- {
- cout << przedzialy2[i] << "\n";
- }
- int z;
- cin >> z;
- return 0;
- }
Add Comment
Please, Sign In to add comment