Rabu, 15 Juni 2011

Identity Matrix

On this occasion I will post the program on the following matrix identity is a little explanation from me, the notion of the identity matrix is a matrix whose diagonal elements main equal to 1, while other elements have the same with 0.
we just created the program, and the following source code:

#include <iostream.h>
#include <conio.h>
int main()
{
  int a[99] [99];
  int i, j, n;
cout << "nilai n: ";
cin >> n;
  for ( i = 0; i <= n; i++ )
  {
    for ( j = 0; j <= n; j++ )
      if ( i == j )
        a[i] [j] = 1;
      else
        a[i] [j] = 0;
  }
  for ( i = 0; i < n; i++ )
  {
    for ( j = 0; j < n; j++ )
      cout << a[i] [j];
    cout << endl;
  }
  getch();


Display after it was written in Borland C + + are as follows: 
 hopefully this program can be useful matrix identity and thanks ^_^


 

0 komentar:

Posting Komentar