-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path1183.c
51 lines (47 loc) · 791 Bytes
/
1183.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
#include<stdio.h>
#define tam 12
int main (){
int i, j;
double soma=0, media=0, a[tam][tam];
char op;
fflush(stdin);
scanf("%c", &op);
for (i=0; i<tam; i++){
for(j=0; j<tam; j++){
scanf("%lf", &a[i][j]);
//a[i][j] = rand() % 10;
}
}
/*
//Apresenta Matriz
for (i=0; i<tam; i++){
printf("\n");
for(j=0; j<tam; j++){
//scanf("%lf", &a[i][j]);
printf("%.2lf ", a[i][j]);
}
}
*/
//Verifica Diagonal
if (op == 'S'){
for (i=0; i<tam; i++){
for(j=0; j<tam; j++){
if(i<j){
soma += a[i][j];
}
}
}
printf("%.1lf\n", soma);
}else if (op == 'M'){
for (i=0; i<tam; i++){
for(j=0; j<tam; j++){
if(i<j){
soma += a[i][j];
media = (soma/(((tam*tam)-tam)/2));
}
}
}
printf("%.1lf\n", media);
}
return 0;
}