-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrincando_matrizes.c
96 lines (79 loc) · 1.71 KB
/
brincando_matrizes.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <stdio.h>
#include <string.h>
#define MAX 1000001
int delta_3(int m, int a[][m])
{
int delta = 0;
int p_sum = (a[0][0]*a[1][1])*a[2][2] + a[0][1]*(a[1][2]*a[2][0]) + a[0][2]*(a[1][0]*a[2][1]);
int n_sum = (a[0][0]*a[1][2])*a[2][1] + a[0][1]*(a[1][0]*a[2][2]) + a[0][2]*(a[1][1]*a[2][0]);
printf("%d\t", p_sum);
printf("%d\n", n_sum);
delta = p_sum - n_sum;
return delta;
}
int great(int m, int a[][m], int N)
{
int i,j;
int maior = 0;
for ( i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
if(i==0 && j == 0)
{
maior = a[i][j];
}
if (maior<a[i][j])
{
maior = a[i][j];
}
//printf("MAIOR[%d][%d]:%d\n",i,j,maior);
}
}
return maior;
}
int main()
{
int i,j;
int matrix[3][3];
for (i = 0; i < 3; i++)
{
for ( j = 0; j < 3; j++)
{
int n;
scanf("%d",&n);
matrix[i][j] = n;
//printf("matrix[%d][%d] = %d\t",i,j,n);
}
//printf("\n");
}
int sum = 0;
for (i = 0; i < 3; i++)
{
for ( j = 0; j < 3; j++)
{
sum = sum + matrix[i][j];
}
}
double media = (double) sum/9;
printf("%.2lf ",media);
int delta;
int maior = great(3,matrix,9);
printf("%d ", maior);
if (maior > 0)
{
delta = 1;
}
else if (maior < 0)
{
delta = -1;
}
else
{
delta = 0;
}
printf("%d ",delta);
int princ = matrix[0][0]+matrix[1][1]+matrix[2][2];
printf("%d\n",princ);
return 0;
}