Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <ctime>
- #include <cstdlib>
- #include <cmath>
- typedef std::vector<std::vector<double>> matrix;
- inline double _rand(double a, double b)
- {
- return a + (rand() % 10001) / 10000.0 * (b - a);
- }
- matrix createMatrix(int m, int n)
- {
- srand(time(NULL));
- matrix mat(m, std::vector<double>(n));
- double fi = _rand(0, 1.) * 2*3.141592654;
- int limit = _rand(0.6, 1.) * sqrt(m*n), br(limit);
- for (int i(0); i < m; i++)
- for (int j(0); j < n; j++)
- {
- double f, A(rand() % 100);
- if (rand() % int(pow(m*n, 0.2)) == 0) A = 20*pow(1.5, _rand(1., 1.5));
- if (rand() % 7 == 0) A = 300*pow(1.5, _rand(1., 13.));
- mat[i][j] = int(A*(1+pow(sin(2*3.141592654*f * (i*n+j) + fi), 25)));
- br++;
- if (br == limit)
- {
- br = 0;
- f = sqrt(m*n) * _rand(0.3, 1.5);
- limit = _rand(0.6, 1.) * sqrt(m*n);
- }
- }
- return mat;
- }
- int main()
- {
- int a, b;
- std::cin >> a >> b;
- std::cout<<"START\n";
- for (std::vector<double> red : createMatrix(a, b))
- {
- for (double el : red)
- std::cout << el << " ";
- std::cout << "\n";
- }
- std::cout<<"END";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement