URI Problem (Inferior Area) 1188:
Inferior Area is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.
import java.util.Scanner; /** * @Author : Muhammad Harun-Or-Roshid * @Date : Oct 28, 2016 * @Time : 3:45:36 PM */ public class Uri1188 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double m[][] = new double[12][12]; double sum = 0; int count = 0; String v = sc.next(); for (int i = 0; i < m.length; i++) { for (int j = 0; j < m.length; j++) { double x = sc.nextDouble(); m[i][j] = x; if (j < i && j > (m.length - i - 1)) { sum += x; count++; } } } if (v.equals("S")) { System.out.printf("%.1f\n", sum); } else { System.out.printf("%.1f\n", (sum / count)); } } }