1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| import java.io.Console;
public class Test {
public static int[][] saisie1(int n, int m) {
int t[][], i, j;
Console console = System.console();
if (console == null) {
System.out.println("Can't get console");
System.exit(-1);
}
t = new int[n][m];
for (i = 0; i < t.length; i++) {
for (j = 0; j < t[0].length; j++) {
System.out.println("valeur de la case " + (i + 1) + " " + (j + 1)
+ " ? ");
t[i][j] = Integer.parseInt(console.readLine("[%d]", t[i][j]));
}
}
for (i = 0; i < t.length; i++) {
for (j = 0; j < t[0].length; j++) {
System.out.println("valeur de la case " + (i + 1) + " " + (j + 1)
+ " : " + t[i][j]);
}
}
return t;
}
public static void main(String args[]) {
int n = Integer.parseInt(args[0]);
int m = Integer.parseInt(args[1]);
saisie1(n, m);
}
} |
Partager