Advertisement
s00rk

Ruben Fernandez

Oct 17th, 2012
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     static int N = 5;
  7.     int matriz[N][N];
  8.  
  9.     cout << "Matriz Identidad" << endl;
  10.     for(int i = 0; i < N; i++)
  11.     {
  12.         for(int j = 0; j < N; j++)
  13.         {
  14.             matriz[i][j] = ((i == j) ? 1 : 0);
  15.             cout << matriz[i][j] << " ";
  16.         }
  17.         cout << endl;
  18.     }
  19.  
  20.     cout << endl << "Matriz Invertida" << endl;
  21.     for(int i = N-1; i >= 0; i--)
  22.     {
  23.         for(int j = 0; j < N; j++)
  24.         {
  25.             matriz[i][j] = ((i == j) ? 1 : 0);
  26.             cout << matriz[i][j] << " ";
  27.         }
  28.         cout << endl;
  29.     }
  30.     cin.get();
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement