fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int arr[][]={{1},{2,2},{5,2,2},{2,0,5,8},{8,7,9,4,5}};
  13.  
  14. int size=5;
  15.  
  16. for(int x=0; x < size; x++)
  17. {
  18. int sum = 0;
  19. for(int y=x; y < size; y++)
  20. {
  21. sum += arr[y][x];
  22. }
  23. System.out.println("Column " + x + " Sum=" + sum + "\n");
  24. }
  25. }
  26. }
Success #stdin #stdout 0.1s 320512KB
stdin
Standard input is empty
stdout
Column 0 Sum=18

Column 1 Sum=11

Column 2 Sum=16

Column 3 Sum=12

Column 4 Sum=5