-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1190.c
More file actions
82 lines (47 loc) · 934 Bytes
/
1190.c
File metadata and controls
82 lines (47 loc) · 934 Bytes
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
#include <stdio.h>
double sum_rec(float M[][12]){
double sum = 0.0;
int k = 0;
for(int i = 7; i < 12; i++){
for(int j = 0; j <= k; j++){
sum += M[5-j][i] + M[6+j][i];
}
k++;
}
return sum;
}
double mult_rec(float M[][12]){
double mult = 1.0;
int k = 0;
for(int i = 7; i < 12; i++){
for(int j = 0; j <= k; j++){
mult *= M[5-j][i] * M[6+j][i];
}
k++;
}
return mult;
}
float op_line(float matriz[][12], char op){
switch (op)
{
case 'S':
return sum_rec(matriz);
break;
case 'M':
return mult_rec(matriz);
break;
}
}
int main(){
float matriz[12][12];
int size = sizeof(matriz[0])/sizeof(matriz[0][0]);
char op;
scanf("%c", &op);
for(int i = 0; i < 12; i++){
for(int j = 0; j < 12; j++){
scanf("%f", &matriz[i][j]);
}
}
printf("%.1lf\n", op_line(matriz, op));
return 0;
}