greannmhar

printMatrix

Nov 5th, 2025
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. void printMatrix(int l, int n, double *A, int r) {
  5. int rows_to_show = std::min(l, r);
  6. int cols_to_show = std::min(n, r);
  7. for (int i = 0; i < rows_to_show; ++i) {
  8. for (int j = 0; j < cols_to_show; ++j) {
  9. std::cout << " " << std::scientific << std::setprecision(3) << A[i * n + j];
  10. }
  11. std::cout << std::endl;
  12. }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment