diff --git a/.vscode/settings.json b/.vscode/settings.json index e112a70..62fe69d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,9 @@ "java.project.outputPath": "bin", "java.project.referencedLibraries": [ "lib/**/*.jar" + ], + "cSpell.words": [ + "complexite", + "Poignee" ] } diff --git a/bin/C10_Tri_et_complexite/C102_Complexite_algorithmique/Poignee_de_main.class b/bin/C10_Tri_et_complexite/C102_Complexite_algorithmique/Poignee_de_main.class index ef890c2..60ae7d3 100644 Binary files a/bin/C10_Tri_et_complexite/C102_Complexite_algorithmique/Poignee_de_main.class and b/bin/C10_Tri_et_complexite/C102_Complexite_algorithmique/Poignee_de_main.class differ diff --git a/src/C10_Tri_et_complexite/C102_Complexite_algorithmique/Poignee_de_main.java b/src/C10_Tri_et_complexite/C102_Complexite_algorithmique/Poignee_de_main.java index d7b13d3..5da31e4 100644 --- a/src/C10_Tri_et_complexite/C102_Complexite_algorithmique/Poignee_de_main.java +++ b/src/C10_Tri_et_complexite/C102_Complexite_algorithmique/Poignee_de_main.java @@ -1,7 +1,24 @@ package C10_Tri_et_complexite.C102_Complexite_algorithmique; +// Nombre de poignées de mains échangées pour n personnes. public class Poignee_de_main { + public static void main(String[] args) throws Exception { - System.out.println("Hello, World!"); + new Poignee_de_main(10); } + + private int n; + private long checks = 0; + + Poignee_de_main(int n){ + this.n = n; + compute(); + System.out.println("Poignées de mains échangée: " + checks); + } + + private void compute() { + for (int i = n-1; i >= 1; i--) { + checks += i; + } + } }