Version without JavaScript, read-only: workshops, quizzes and running code are not available here. Full version · Catalogue · Sign in
Sequence
3×3 matrix
Core exercise
Write construireMatrice() that returns an int[3][3] containing the numbers from 1 to 9 in order, and afficherMatrice(int[][] matrice) that prints it row by row.
A workshop goes here: you write and run code in it. It requires JavaScript.
Starting code
Exercices.java
public class Exercices {
public static void main(String[] args) {
afficherMatrice(construireMatrice());
}
public static int[][] construireMatrice() {
// TODO : remplir une matrice 3x3 avec 1 a 9
return new int[3][3];
}
public static void afficherMatrice(int[][] matrice) {
// TODO : une ligne par ligne de la matrice
}
}
The core exercise is validated in the workshop, which requires JavaScript.
Hint 1
Two nested loops. A counter incremented at each filled cell saves you from computing i * 3 + j + 1.