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};

4th Jun 2018, 8:05 AM
Gheorghita Marcel
Gheorghita Marcel - avatar
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
4th Jun 2018, 8:36 AM
Gheorghita Marcel
Gheorghita Marcel - avatar
+ 1
Thank you very much. ))
4th Jun 2018, 11:23 AM
Gheorghita Marcel
Gheorghita Marcel - avatar
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(); } } } }
4th Jun 2018, 10:07 AM
Gheorghita Marcel
Gheorghita Marcel - avatar
0
what about this? how can i find them in this way? i don’t know how ro use scanner
4th Jun 2018, 10:08 AM
Gheorghita Marcel
Gheorghita Marcel - avatar