#12 hlucheucho
Vrelá vdaka....
#include <stdio.h>
#define A 4
#define B 4
double matica[A][B]; //staticke pole
void nacitaj_maticu(double *matica);
void priemer_diagonaly(double a,double b,double c,double d);
void priemer_pod(double a,double b,double c);
void priemer_nad(double a,double b,double c);
int main (void)
{
nacitaj_maticu(*matica);
priemer_diagonaly(matica[0][0],matica[1][1],matica[2][2],matica[3][3]);
priemer_pod(matica[2][1],matica[3][2],matica[4][3]);
priemer_nad(matica[1][2],matica[1][3],matica[3][4]);
return 0;
}
void nacitaj_maticu(double *matica)
{
int i, j;
printf("matica s rozmermi %d x %d\n", A, B);
for( i = 0 ; i < A ; i++)
{
for( j = 0 ; j < B ; j++)
{
printf("Vlozte prvok matice A[%d,%d].\t",i+1,j+1);
scanf("%lf", &matica[i * A + j]);
}
}
}
void priemer_diagonaly(double a,double b,double c,double d)
{
double p;
p = (a + b + c + d) / 4;
printf("priemer na diagonale je %.4lf.\n",p);
}
void priemer_pod(double a,double b,double c)
{
double p;
p = (a + b + c) / 3;
printf("priemer pod diagonalou je %.4lf.\n",p);
}
void priemer_nad(double a,double b,double c)
{
double p;
p = (a + b + c) / 3;
printf("priemer nad diagonalou je %.4lf.\n",p);
}
tak spravil som to takto...mam ale problem s priemermy nad a pod diagonalou ... hadze mi zle vysledky nerozumiem preco a priemer na diagonale mi vypocita vzdy spravne