martes, 9 de noviembre de 2010

Metodos de ordenamiento

PROGRAMA QUE CAPTURA VALORES NUMERICOS DE UNA MATRIZ DE 4X4 Y CALCULA LA SUMA Y EL PROMEDIO DE ESTA DE LA DIAGONAL PRINCIPAL DE LA MATRIZ.

#include<conio.h>
#include<iostream.h>

void main()
{
clrscr();
int i,j,k,l;
int a[4][4];
float prom,prom1;
cout<<"Introduze tus valores:\n"<<endl;
for(i=0;i<4;i++){
   for(j=0;j<4;j++){
      cin>>a[i][j];
}
}
cout <<"\nLos valores de la matriz son: \n "<<endl;
for(i=0;i<4;i++){
   for(j=0;j<4;j++){

cout<<a[i][j]<<" ";
}
cout<<"  \n "<<endl;
}
for(i=0;i<4;i++){
   for(j=0;j<4;j++){
if(i==j)

prom=prom+a[i][j];


}

}
prom1=prom/4;
cout<<"LA SUMA DE LA DIAGONAL ES : "<<prom<<endl;
cout<<"EL PROMEDIO DIAGONAL ES : "<<prom1<<endl;
getch();
}

1 comentario: