Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <ctime>
  4. #include <cstdlib>
  5.  
  6. typedef std::vector<std::vector<double>> matrix;
  7.  
  8. matrix _createMatrix(int rows, int columns)
  9. {
  10. return matrix(rows, std::vector<double>(columns));
  11. }
  12.  
  13. matrix createMatrix(int rows, int columns)
  14. {
  15. srand(time(NULL));
  16. matrix m(_createMatrix(rows, columns));
  17. for (int y(0); y < rows; y++)
  18. for (int x(0); x < columns; x++)
  19. if (rand() % 10 == 2 && x >= columns / 6 && x <= columns % 6 && y >= rows / 6 && y <= rows % 6)
  20. m[y][x] = rand() % 100 + (76 * (x+y));
  21. else if (x >= columns / 3 && x <= columns % 3 && y >= rows / 3 && y <= rows % 3)
  22. m[y][x] = rand() % 100 + (10 * (x+y));
  23. else if (x >= columns / 2 && x <= columns % 2 && y >= rows / 2 && y <= rows % 2)
  24. m[y][x] = rand() % 50 + (2 * (x+y)) / double(0*rand() % 10+1);
  25. else
  26. m[y][x] = rand() % 20 + (x+y) / double(0*rand() % 10+1);
  27. return m;
  28. }
  29.  
  30. int main()
  31. {
  32. int a, b;
  33. std::cin >> a >> b;
  34. std::cout<<"START\n";
  35. for (std::vector<double> red : createMatrix(a, b))
  36. {
  37. for (double el : red)
  38. std::cout << el << " ";
  39. std::cout << "\n";
  40. }
  41. std::cout<<"END";
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement