update
This commit is contained in:
31
DEV.2.1/TP/TP1-introduction/Grille.java
Normal file
31
DEV.2.1/TP/TP1-introduction/Grille.java
Normal file
@@ -0,0 +1,31 @@
|
||||
public class Grille {
|
||||
public static void main(String[] args) {
|
||||
// Vérification de la validité de l'argument
|
||||
if (args.length == 0 || Integer.parseInt(args[0]) <= 0) {
|
||||
System.out.println("Pas de tableau");
|
||||
} else {
|
||||
int taille = Integer.parseInt(args[0]);
|
||||
|
||||
// Construction de la grille
|
||||
for (int i = 0; i < taille; i++) {
|
||||
// Ligne horizontale
|
||||
for (int j = 0; j < taille; j++) {
|
||||
System.out.print("+-");
|
||||
}
|
||||
System.out.println("+");
|
||||
|
||||
// Ligne verticale
|
||||
for (int j = 0; j < taille; j++) {
|
||||
System.out.print("| ");
|
||||
}
|
||||
System.out.println("|");
|
||||
}
|
||||
|
||||
// Dernière ligne horizontale
|
||||
for (int j = 0; j < taille; j++) {
|
||||
System.out.print("+-");
|
||||
}
|
||||
System.out.println("+");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user