forked from menault/TD4_DEV51_Qualite_Algo
Add: File
This commit is contained in:
29
TriTableauND.java
Normal file
29
TriTableauND.java
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
public class TriTableauND {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int[][] tableau = { {0,3,2}, {9,4,5}, {4,1,3} };
|
||||||
|
|
||||||
|
trier2D(tableau);
|
||||||
|
|
||||||
|
for (int[] ligne : tableau) {
|
||||||
|
System.out.println(Arrays.toString(ligne));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void trier2D(int[][] tab) {
|
||||||
|
|
||||||
|
for (int[] ligne : tab) {
|
||||||
|
Arrays.sort(ligne);
|
||||||
|
}
|
||||||
|
Arrays.sort(tab, Comparator.comparingInt(TriTableauND::somme));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int somme(int[] t) {
|
||||||
|
int s = 0;
|
||||||
|
for (int val : t) s += val;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
0
function1.py
Normal file
0
function1.py
Normal file
0
function2.py
Normal file
0
function2.py
Normal file
11
function3.py
Normal file
11
function3.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
def function_3(x):
|
||||||
|
valeur = 0
|
||||||
|
if x < 0:
|
||||||
|
valeur = -x
|
||||||
|
if x == 0:
|
||||||
|
pass
|
||||||
|
if x > 0:
|
||||||
|
valeur = x
|
||||||
|
return valeur
|
||||||
|
|
||||||
|
function_3(5)
|
Reference in New Issue
Block a user