83 lines
1.9 KiB
Java
83 lines
1.9 KiB
Java
public class Tableaux{
|
|
|
|
public static int[] RemplisTableaux(String[] arguments, int val, int[] tab){
|
|
if (val == (arguments.length-1)){
|
|
tab[val]=Integer.parseInt(arguments[val]);
|
|
return tab;
|
|
}else{
|
|
tab[val]=Integer.parseInt(arguments[val]);
|
|
return RemplisTableaux(arguments, val+1, tab);
|
|
}
|
|
}
|
|
|
|
public static int AfficheTableaux(int[] tab, int val){
|
|
if (val == (tab.length-1)){
|
|
System.out.println(tab[val]+" ");
|
|
return 0;
|
|
}else{
|
|
System.out.print(tab[val]+" ");
|
|
return AfficheTableaux(tab, val+1);
|
|
}
|
|
}
|
|
|
|
public static int EntierPairs(int[] tab, int val, int pair){
|
|
if (val == (tab.length-1)){
|
|
if ((tab[val]%2)==0){
|
|
pair++;
|
|
return pair;
|
|
}else{
|
|
return pair;
|
|
}
|
|
}else{
|
|
if ((tab[val]%2)==0){
|
|
return EntierPairs(tab, val+1, pair+1);
|
|
}else{
|
|
return EntierPairs(tab, val+1, pair);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static int Maximum(int[] tab, int val, int maxi){
|
|
if (val == (tab.length-1)){
|
|
if (tab[val]>maxi){
|
|
return tab[val];
|
|
}else{
|
|
return maxi;
|
|
}
|
|
}else{
|
|
if (tab[val]>maxi){
|
|
return Maximum(tab, val+1, tab[val]);
|
|
}else{
|
|
return Maximum(tab, val+1, maxi);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static int[] InverseTableaux(int[] tab, int val){
|
|
if (val == ((tab.length/2)-1)){
|
|
int temp=tab[val];
|
|
tab[val]=tab[(tab.length-1)-val];
|
|
tab[(tab.length-1)-val]=temp;
|
|
return tab;
|
|
}else{
|
|
int temp=tab[val];
|
|
tab[val]=tab[(tab.length-1)-val];
|
|
tab[(tab.length-1)-val]=temp;
|
|
return InverseTableaux(tab, val+1);
|
|
}
|
|
}
|
|
|
|
public static void main(String args[]){
|
|
int i=0;
|
|
int longueur=args.length;
|
|
int[] tab=new int[longueur];
|
|
tab = RemplisTableaux(args, 0, tab);
|
|
AfficheTableaux(tab, 0);
|
|
int p = EntierPairs(tab, 0, 0);
|
|
System.out.println("Le tableau contient "+p+" nombre pair.");
|
|
int m = Maximum(tab, 0, 0);
|
|
System.out.println("Le plus grand chiffre du tableau est: "+m);
|
|
tab = InverseTableaux(tab, 0);
|
|
AfficheTableaux(tab, 0);
|
|
}
|
|
} |