0
Prime numbers in java.
I have a matrix and i need to find in even line the prime number. How can i do that? My matrix is: int matrix [][]=new int [3][]; matrix [0]=new int []{1,2,3}; matrix [1]=new int []{1,2,3}; matrix [2]=new int []{1,2,3};
4 Antworten
+ 1
yeah but how? should i use “for” and “if”. i tried a lot of exemples and still cant. i tries and exemples from inet, but they are not for beginers, i want smth simple to understand the syntax
+ 1
Thank you very much. ))
0
public class ArrayProblem
public static void main(String[] args) {
int matrice[][] = new int[3][];
matrice[0] = new int[] { 1, 2, 3 };
matrice[1] = new int[] { 2, 1, 3 };
matrice[2] = new int[] { 3, 2, 1 };
for (int i = 1; i < matrice.length - 1; i++) {
for (int k=0; k<matrice[i].length;k++) {
if (i % 2 == 1) {
}System.out.println();
}
}
}
}
0
what about this? how can i find them in this way? i don’t know how ro use scanner