Rabu, 03 Oktober 2012

Program Matriks

NAMA : FAHMI SUTARNO
NIM      : 12018084
KELAS : B

 #include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    cout<< 1 " program matriks"endl;
    cout<< 2 " nshgnemvkbdje"endl;
     int n,mtx=0,mtx1=0;
    cout<<"----PENGECEKAN MATRIX DIAGONAL----"<<endl<<endl;
    cout<<"\nMasukkan  Matrix =";
    cin>>n;
    cout<<"\nMatrix  "<<n<<" X "<<n<<endl<<endl;
   
    int mtrx[n][n];

for (int x = 0; x <n; x++ ){
    for (int y = 0; y <n; y++){
        cout<<"Masukkan  Matrix ["<<x<<"]["<<y<<"] =";
        cin>>mtrx[x][y];
                      }
                }
       
cout<<endl<<endl;

for (int x = 0; x <n; x++ ){
    for (int y = 0; y <n; y++){
        cout<<mtrx[x][y]<<" ";
                      }
              cout<<endl;
                 }
       
for ( int x = 0; x <n; x++ ){
    for ( int y = 0; y <n; y++){   
        if ( x == y && mtrx[x][y]==1){
        mtx=mtx+1;     
           }
        if ( x != y && mtrx[x][y]==0){
        mtx1=mtx1+1;
           }                    
                      }
                 }
        cout<<endl;
    if ( mtx == n && mtx1 == (n*n)-n){
       cout<<"ok!! Matrix Diagonal"<<endl<<endl;
    }else{
       cout<<"bukan!! bukan Matrix Diagonal"<<endl<<endl;
    }
    system("PAUSE");
    return
   
     EXIT_SUCCESS;
}



fahmi,s blogPosted By Fahmi's BLog

Semoga informasi yang Fahmi's sampaikan sangat bermanfaat bagi Kita semua contact me

Thank You

0 komentar:

Posting Komentar