Matrice patratica

1.Diagonala principala:

a)pe diagonala-a[i][j] , i=j , i=1,n; j=1,n;

a[i][i] , i=1,n;

b)deasupra diagonalei-a[i][j] , i=1,n; j=1,n;

a[i][j], i=1,n-1; j=i+1,n;

c)sub diagonala-a[i][j] , i>j , i=1,n; j=1,n;

a[i][j] , i=2,n; j=1,i-1;

2.Diagonala secundara:

a)pe diagonala-a[i][j] , i+j=n+1; i=1,n; j=1,n;

j=n+1-i;

b)deasupra diagonalei-a[i][j] , i+j<n+1; i=1,n; j=1,n;

j<n+1-i;

i=1,n; j=1,n-i;

c)sub diagonala-a[i][j] , i+j>n+1; i=1,n; j=1,n;

j<n+1-i;

i=2,n; j=n+2-i,n;

3. Zone

a) Zona Sudica-i>j, i+j>n+1

b) Zona Nordica-i<j, i+j<n+1

c) Zona Estica-i<j, i+j>n+1

d) Zona Vestica-i>j, i+j<n+1

4. Simetrii

a) Diagonala principală

for(i=1;i<=n-1&&OK==1;++i)

for(j=i+1;j<=n&&OK==1;++j)

if(a[i][j]!=a[j][i]) OK=0;

b) Diagonala secundara

for(i=1;i<=n-1&&OK==1;++i)

for(j=i+1;j<=n-i&&OK==1;++j)

if(a[i][j]!=a[n+1-j][n+1-i]) OK=0;

c) Axa Ox

if(a[i][j]!=a[n+1-i][j]) OK=0;

d) Axa Oy

if(a[i][j]!=a[i][n+1-j])OK=0

Advertisements

Interclasare

-2 vectori ordonati descrescator => un vector ordonat crescactor-
#include <iostream>
using namespace std;
int main()
 {
 int x[20],y[40],z[60],i,j,m,n,k=0;
 cin>>n>>m;
 for(i=1;i<=n;++i) cin>>x[i];
 for(i=1;i<=m;++i) cin>>y[i];
 i=n;j=m;k=0;
 while(i>=1&&j>=1)
 { if(x[i]<y[j]) z[++k]=x[i–-];
   else z[++k]=y[j–-];
 }
 while(i>=1) z[++k]=x[i–-];
 while(j>=1) z[++k]=y[j–-];
 for(i=k;i>1;++i) cout<<z[i]<<",";
 cout<<z[1];
 return 0;
 }