From 45b2a3e52766227950867e3cc38c95e55c1a8119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Mon, 7 Mar 2022 17:15:30 +0100 Subject: [PATCH] =?UTF-8?q?exercice:=20Poign=C3=A9es=20de=20main?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 4 ++++ .../Poignee_de_main.class | Bin 702 -> 1157 bytes .../Poignee_de_main.java | 19 +++++++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) 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 ef890c24fefbc918cbadab7566b0f1dabcda1e2b..60ae7d3de501ae8de15bef2259ec2f821995aff5 100644 GIT binary patch literal 1157 zcmb_c+fEZv6kVsS3>~K2FUrm0jZ%;TUQmkH1`|kC5(o+Lp&6zpIK$Ej6o$WG>C4rE>AT_;h; zUzjE3Wu*ziTIfJ0G3J%4{D=G!ThwXV(#n-DDuoSMTD3RwQlK;KId*={E-7s{oFTiE zBeAY?$e0M?qRxIvAQ&543lnX?f`Mjz8nSQ!O`5@F3sD_oX!$C>4C4x}8Mt~%l9jh* zUluG}#|>ulDpaSZUcd4Z%Piif1kx@f4a5ZcPHL_z^R%M!Sy^gEoOm_$4|iobnw3$l zW;uGe>ugeaI_IJ$Mlqpz-y}xtJdt%o!on1$sheFaN;fMo7+V@U6WqW}>KnH#+{PV& zX5Xum66lVdy~5a8+&6IVPwP$>XkkthGm5(AJO?4G0) z0MTylqwN!o0J`|r!O(-k)y zK^F=xdI0a?0la`XiJ)%Y`FUp^W*&^0D&D`|W&noRPK0Zf_WZz)_X&k=Z%im2gcDDo z0KLXhLN0f1lC|_XcOxBo*z0VksrjPIPzRxU58E3F0+;l2#xO1KYYyX>27bFn$%7| zmBB5bfU@&gHGak6NF3GvEA%H$6bRPL2ES5fHGc*;R=6@Shk2f=a$aO-A;%1JEW6LB e*H&Jz`iBy1F&{cZ%dKCYfetpfB5blM*!l)u#W?@~ 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; + } + } }