I'm doing exercises at uri online judge, this one asks:
In this problem you should read a number, indicating an array line in which an operation must be performed, a capital character, indicating the operation to be performed, and all elements of a M[12][12]
array.
Then calculate and show the sum or mean of the elements that are in the green area of the matrix, as the case may be. The first entry line contains an L number indicating the line that will be considered for operation. The second input line contains a single character T ('S' or 'M'), indicating the operation (Sum or Average) to be performed with the array elements.
The following are the 144 floating-point values that make up the array, which is filled line by line, from line 0 to line 11, always from left to right.
Output
Print the requested result (the sum or average), with 1 house after the decimal point.
#include <stdio.h>
main() {
float M[12][12];
int linha, l, coluna;
char T;
float calculo;
scanf("%d", &l);
scanf("%c", &T);
for(linha = 0; linha < 12; linha ++){
for(coluna = 0; coluna < 12; coluna ++){
scanf("%f", &M[linha][coluna]);
}
}
if (T == 'M'){
for(coluna = 0; coluna < 12; coluna ++){
calculo = calculo + M[l][coluna];
}
calculo = calculo/12;
}
else {
for (coluna = 0; coluna < 12; coluna ++){
calculo = calculo + M[l][coluna];
}
}
printf ("%0.1f", calculo);
}
The program does not read the array and gives an error. Thank you for helping me, thank you:)