a
This commit is contained in:
9
APL2.1/TP1_Introduction/Arguments.java
Normal file
9
APL2.1/TP1_Introduction/Arguments.java
Normal file
@@ -0,0 +1,9 @@
|
||||
public class Arguments{
|
||||
|
||||
public static void main(String args[]){
|
||||
|
||||
for(int compteur=0;compteur<args.length;compteur++){
|
||||
System.out.println("Bonjour "+args[compteur]);
|
||||
}
|
||||
}
|
||||
}
|
||||
17
APL2.1/TP1_Introduction/Bonjour.java
Normal file
17
APL2.1/TP1_Introduction/Bonjour.java
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Cette classe est une simple coquille pour recevoir la méthode principale
|
||||
*
|
||||
* @version 1.1 09 March 2014
|
||||
* @author Luc Hernandez
|
||||
*/
|
||||
public class Bonjour {
|
||||
|
||||
/**
|
||||
* Affiche «Bonjour !»
|
||||
*
|
||||
* @param args la liste des arguments de la ligne de commande (inutilisée ici)
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Bonjour !");
|
||||
}
|
||||
}
|
||||
25
APL2.1/TP1_Introduction/Demarrage.java
Normal file
25
APL2.1/TP1_Introduction/Demarrage.java
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Cette classe est une simple coquille pour recevoir la méthode principale
|
||||
*
|
||||
* @version 1.1 09 March 2014
|
||||
* @author Luc Hernandez
|
||||
*/
|
||||
public class Demarrage {
|
||||
|
||||
/**
|
||||
* Affiche «Bonjour !»
|
||||
*
|
||||
* @param args la liste des arguments de la ligne de commande (inutilisée ici)
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
byte a = 1;
|
||||
int b = 2;
|
||||
boolean c = true;
|
||||
char d = 'A';
|
||||
double e = 5.1d;
|
||||
float f = 6.2f;
|
||||
short g = 7;
|
||||
long h = 8L;
|
||||
System.out.println(a+" "+b+" "+c+" "+d+" "+e+" "+f+" "+g+" "+h);
|
||||
}
|
||||
}
|
||||
20
APL2.1/TP1_Introduction/Grille.java
Normal file
20
APL2.1/TP1_Introduction/Grille.java
Normal file
@@ -0,0 +1,20 @@
|
||||
public class Grille{
|
||||
public static void main(String args[]){
|
||||
|
||||
int taille = Integer.parseInt(args[0]);/*On convertie l'argument en entier*/
|
||||
|
||||
for(int compteurLigne=0;compteurLigne<taille;compteurLigne++){/**/
|
||||
|
||||
for(int compteur=0;compteur<taille;compteur++) System.out.print("+-");
|
||||
|
||||
System.out.println("+");
|
||||
|
||||
for(int compteur=0;compteur<taille;compteur++) System.out.print("| ");
|
||||
|
||||
System.out.println("|");
|
||||
}
|
||||
for(int compteur=0;compteur<taille;compteur++) System.out.print("+-");
|
||||
|
||||
if(taille!=0) System.out.println("+");
|
||||
}
|
||||
}
|
||||
11
APL2.1/TP1_Introduction/Somme.java
Normal file
11
APL2.1/TP1_Introduction/Somme.java
Normal file
@@ -0,0 +1,11 @@
|
||||
public class Somme{
|
||||
|
||||
public static void main(String args[]){
|
||||
|
||||
int resultat=0;
|
||||
for(String valeurActuelle : args){
|
||||
resultat+=Integer.parseInt(valeurActuelle);
|
||||
}
|
||||
System.out.println("Le résultat est : "+resultat);
|
||||
}
|
||||
}
|
||||
20
APL2.1/TP1_Introduction/Tri.java
Normal file
20
APL2.1/TP1_Introduction/Tri.java
Normal file
@@ -0,0 +1,20 @@
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Tri{
|
||||
|
||||
public static void main(String args[]){
|
||||
|
||||
int[] tableauEntier = new int[args.length];
|
||||
|
||||
for(int compteur=0;compteur<args.length;compteur++){
|
||||
tableauEntier[compteur]=Integer.parseInt(args[compteur]);
|
||||
}
|
||||
Arrays.sort(tableauEntier);
|
||||
|
||||
for(int valeurActuelle : tableauEntier ){
|
||||
System.out.print(valeurActuelle+",");
|
||||
}
|
||||
|
||||
System.out.print("\n");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user