Valeri173

Untitled

Feb 19th, 2021
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. public class Chas1 {
  2.  
  3. public static void main(String[] args ){
  4. int[][] arr = {
  5. {1, 3, 5, 7},
  6. {2, 4, 6, 8},
  7. {1, 3, 5, 7},
  8. {2, 4, 6, 8}
  9. };
  10. int sum = 0, j = 3;
  11. for (int i = 0; i < arr.length; i++) {
  12. j = i;
  13. sum+=arr[i][j];
  14. }
  15. System.out.println(sum);
  16.  
  17. /*
  18. for (int i = 0; i < arr.length; i++) {
  19. sum+=arr[i][j];
  20. j--;
  21. }
  22. System.out.print(sum);
  23. */
  24.  
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment