Home
Classrooms
Courses
About Us
Resources
Members
More
class Main { public static void main(String[] args) { int N = 4; int M = 3; int A = 3; int B = 2; int count = 0; int[][] NxM = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 } }; for (int y = 0; y < A; y++) { for (int x = 0; x < B; x++) { count = count + NxM[y][x]; } } for (int y = 0; y < A; y++) { for (int x = 1; x <= B; x++) { count = count + NxM[y][x]; } } for (int y = 1; y <= A; y++) { for (int x = 0; x < B; x++) { count = count + NxM[y][x]; } } for (int y = 1; y <= A; y++) { for (int x = 1; x <= B; x++) { count = count + NxM[y][x]; } } System.out.println("Da total is " + count + "."); } }
class Main { public static void main(String[] args) { int N = 4; int M = 3; int A = 3; int B = 2; int count = 0; int[][] NxM = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 } }; for (int y = 0; y < A; y++) { for (int x = 0; x < B; x++) { count = count + NxM[y][x]; } } for (int y = 0; y < A; y++) { for (int x = 1; x <= B; x++) { count = count + NxM[y][x]; } } for (int y = 1; y <= A; y++) { for (int x = 0; x < B; x++) { count = count + NxM[y][x]; } } for (int y = 1; y <= A; y++) { for (int x = 1; x <= B; x++) { count = count + NxM[y][x]; } } System.out.println("Da total is " + count + "."); } }