Solved: 47 - MDSpan

This commit is contained in:
2026-08-24 18:10:37 +03:00
parent 602e5d757b
commit 1e538bdd4b
+12 -13
View File
@@ -2,23 +2,22 @@
namespace cpp23 { namespace cpp23 {
auto make_row_major_matrix(int rows, int cols, int fill) -> std::vector<int> { auto make_row_major_matrix(const int rows, const int cols, const int fill) -> std::vector<int> {
(void)rows; (void)cols; (void)fill; return std::vector(static_cast<size_t>(rows * cols), fill);
return {};
} }
auto matrix_element( auto matrix_element(const std::mdspan<const int, std::extents<int, std::dynamic_extent, std::dynamic_extent>> matrix, const int row, const int col) -> int {
std::mdspan<const int, std::extents<int, std::dynamic_extent, std::dynamic_extent>> matrix, return matrix[row, col];
int row, int col) -> int {
(void)matrix; (void)row; (void)col;
return 0;
} }
auto row_sums( auto row_sums(const std::mdspan<const int, std::extents<int, std::dynamic_extent, std::dynamic_extent>> matrix) -> std::vector<int> {
std::mdspan<const int, std::extents<int, std::dynamic_extent, std::dynamic_extent>> matrix) auto sums = std::vector<int>(matrix.extent(0));
-> std::vector<int> { for (auto i = 0; i < matrix.extent(0); ++i) {
(void)matrix; for (auto j = 0; j < matrix.extent(1); ++j) {
return {}; sums[i] += matrix[i, j];
}
}
return sums;
} }
} // namespace cpp23 } // namespace cpp23