Skip to content

Instantly share code, notes, and snippets.

@totynho
Created July 28, 2016 15:27
Show Gist options
  • Save totynho/4d2287635ee6c25eae70d7ea9c56f125 to your computer and use it in GitHub Desktop.
Save totynho/4d2287635ee6c25eae70d7ea9c56f125 to your computer and use it in GitHub Desktop.
package pacote;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
String operacao = "";
double m[][] = new double[12][12];
Scanner entrada = new Scanner(System.in);
double auxiliar = 0;
int espaco = 1;
operacao = entrada.nextLine();
for (int linha = 0; linha < 12; linha++){
for (int coluna = 0; coluna < 12; coluna++){
m[linha][coluna] = entrada.nextDouble();
}
}
for (int coluna= 11; coluna > 6; coluna--){
for (int linha = (0+espaco); linha < (12-espaco); linha++){
auxiliar += m[linha][coluna];
}
espaco++;
}
switch (operacao) {
case "S":
System.out.println(auxiliar);
break;
case "M":
auxiliar = auxiliar /30;
System.out.println(auxiliar);
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment