Advertisement
rihardmarius

matrices const

Aug 29th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <array>
  3.  
  4. using namespace std;
  5.  
  6. void mostrar_matriz (const array<array<int,3>,3>& a);
  7. void mostrar_matriz_2 (const array<array<int,3>,3>& a);
  8.  
  9. int main()
  10. {
  11.     array<array<int,3>,3> a = {1,2,3,4,5,6,7,8,9};
  12.  
  13.     mostrar_matriz(a);
  14.     mostrar_matriz_2(a);
  15.  
  16.     return 0;
  17. }
  18.  
  19. void mostrar_matriz (const array<array<int,3>,3>& a)
  20. {
  21.     for (int i=0; i<3; i++)
  22.     {
  23.         for (int j=0; j<3; j++)
  24.             cout << a.at(i).at(j) << ' ';
  25.         cout << endl;
  26.     }
  27.     cout << endl;
  28. }
  29.  
  30. void mostrar_matriz_2 (const array<array<int,3>,3>& a)
  31. {
  32.     for (auto f : a)
  33.     {
  34.         for (auto c : f)
  35.             cout << c << ' ';
  36.         cout << endl;
  37.     }
  38.     cout << endl;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement