Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //diagonal matrix
- #include<iostream>
- using namespace std;
- int main()
- {
- int row,column,i,j,ar[10][10],k=0,check1=0,count1=0,countd=0,checkd=0;
- while(1)
- {cout<<"Enter the size of array :"<<endl;
- cin>>row>>column;
- for(i=0;i<row;i++)
- {
- for(j=0;j<column;j++)
- {
- cin>>ar[i][j];
- cout<<ar[i][j]<<" ";
- } cout<<endl;
- }
- for(i=0;i<row;i++)
- {
- for(j=0;j<column;j++)
- {
- if(i!=j)
- {
- if(ar[i][j]==0);
- else k=1;
- }
- else {
- if(ar[i][j]==1){check1=1;}
- else if(ar[i][j]==ar[0][0]){checkd=1;}
- }
- }
- if(k==1) break;
- else if(check1==1){count1++; check1=0;}
- else if(checkd==1){countd++; checkd=0;}
- }
- if(i==row)
- {
- if(count1==row)cout<<"Scalar & Diagonal & Identity Matrix"<<endl;
- else if(countd==row)cout<<"Scalar & Diagonal Matrix"<<endl;
- else cout<<"Diagonal Matrix"<<endl;
- }
- else cout<<"Not Diagonal Not Scalar Not Identity Matrix"<<endl;
- check1=count1=countd=checkd=0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement