Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Chas1 {
- public static void main(String[] args ){
- int[][] arr = {
- {1, 3, 5, 7},
- {2, 4, 6, 8},
- {1, 3, 5, 7},
- {2, 4, 6, 8}
- };
- int sum = 0, j = 3;
- for (int i = 0; i < arr.length; i++) {
- j = i;
- sum+=arr[i][j];
- }
- System.out.println(sum);
- /*
- for (int i = 0; i < arr.length; i++) {
- sum+=arr[i][j];
- j--;
- }
- System.out.print(sum);
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment