Advertisement
Rifftera

Matrix in out

Dec 1st, 2021
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. void inputMatrix(std::vector<std::vector<float>>& matrix, int height, int width) {
  2. matrix.resize(height);
  3. for (int co = 0; co < height; ++co) {
  4. matrix[co].resize(width);
  5. for (int cou = 0; cou < width; ++cou) {
  6. cin >> matrix[co][cou];
  7. }
  8. }
  9. }
  10.  
  11. void outputMatrix(const std::vector<std::vector<float>>& matrix) {
  12. int height = matrix.size();
  13. if (height == 0) return;
  14. int width = matrix[0].size();
  15. cout << '\n';
  16. for (int co = 0; co < height; ++co) {
  17. for (int cou = 0; cou < width; ++cou) {
  18. cout << matrix[co][cou] << " ";
  19. }
  20. cout << '\n';
  21. }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement