diff options
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; +} |
