Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <ctime>
- #include <cstdlib>
- typedef std::vector<std::vector<double>> matrix;
- matrix _createMatrix(int rows, int columns)
- {
- return matrix(rows, std::vector<double>(columns));
- }
- matrix createMatrix(int rows, int columns)
- {
- srand(time(NULL));
- matrix m(_createMatrix(rows, columns));
- for (int y(0); y < rows; y++)
- for (int x(0); x < columns; x++)
- if (rand() % 10 == 2 && x >= columns / 6 && x <= columns % 6 && y >= rows / 6 && y <= rows % 6)
- m[y][x] = rand() % 100 + (76 * (x+y));
- else if (x >= columns / 3 && x <= columns % 3 && y >= rows / 3 && y <= rows % 3)
- m[y][x] = rand() % 100 + (10 * (x+y));
- else if (x >= columns / 2 && x <= columns % 2 && y >= rows / 2 && y <= rows % 2)
- m[y][x] = rand() % 50 + (2 * (x+y)) / double(0*rand() % 10+1);
- else
- m[y][x] = rand() % 20 + (x+y) / double(0*rand() % 10+1);
- return m;
- }
- 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