diff options
| author | Anhgelus Morhtuuzh <anhgelus@anhgelus.world> | 2025-01-31 15:39:30 +0100 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <anhgelus@anhgelus.world> | 2025-01-31 15:39:30 +0100 |
| commit | d7c69934248f3fab4988c0d37c11feba25d653b8 (patch) | |
| tree | 6c396257cb21374e13a26b8f78c05353806220bc /semestre 2/informatique/td/1- exemples/plus_grand.c | |
| parent | ed631f52ee7af474625e37c6855c7c55903317fc (diff) | |
Ajout du début du deuxième semestre
Diffstat (limited to 'semestre 2/informatique/td/1- exemples/plus_grand.c')
| -rw-r--r-- | semestre 2/informatique/td/1- exemples/plus_grand.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/semestre 2/informatique/td/1- exemples/plus_grand.c b/semestre 2/informatique/td/1- exemples/plus_grand.c new file mode 100644 index 0000000..97c47a6 --- /dev/null +++ b/semestre 2/informatique/td/1- exemples/plus_grand.c @@ -0,0 +1,28 @@ +#include <assert.h> + +int plusGrand(int a, int b, int c){ + int max = a; + if (max < b){ + max = b; + } + if (max < c) { + max = c; + } + return max; +} + +int plusGrandParmisCinq(int a, int b, int c, int d, int e){ + return plusGrand(plusGrand(a, b, c), d, e); +} + +int main(){ + assert(plusGrand(1, 2, 3) == 3); + assert(plusGrand(4, 2, 3) == 4); + assert(plusGrand(4, 5, 3) == 5); + assert(plusGrandParmisCinq(1, 2, 3, 4, 5) == 5); + assert(plusGrandParmisCinq(6, 2, 3, 4, 5) == 6); + assert(plusGrandParmisCinq(6, 7, 3, 4, 5) == 7); + assert(plusGrandParmisCinq(6, 7, 8, 4, 5) == 8); + assert(plusGrandParmisCinq(6, 7, 8, 9, 5) == 9); + return 0; +} |
