matrice triunghiulara superior

O matrice patratica cu n linii *  n coloane se numeste triunghiulara superior daca toate elementele aflate sub diagonala principala sunt nule. Realizati un program care verifica daca matricea este triunghiulara superior.

#include<iostream.h>
int a[20][20],i,j,n,g;
void main()
{
cout<<“n=”;cin>>n;
for(i=0;i<=n-1;i++)
for(j=0;j<=n-1;j++)
{
cout<<“a[“<<i<<“][“<<j<<“]=”;
cin>>a[i][j];
}
g=1;
for(i=1;i<=n-1;i++)
for(j=0;j<=i-1;j++)
if(a[i][j]) g=0;
if(g==0)
cout<<“nu este triunghiulara superior”;
else cout<<“este triunghiulara”;
}

{joscommentenable}

Facebook Comments