From d7c69934248f3fab4988c0d37c11feba25d653b8 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Fri, 31 Jan 2025 15:39:30 +0100 Subject: =?UTF-8?q?Ajout=20du=20d=C3=A9but=20du=20deuxi=C3=A8me=20semestre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- semestre 2/informatique/td/1- exemples/signe_somme.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 semestre 2/informatique/td/1- exemples/signe_somme.c (limited to 'semestre 2/informatique/td/1- exemples/signe_somme.c') diff --git a/semestre 2/informatique/td/1- exemples/signe_somme.c b/semestre 2/informatique/td/1- exemples/signe_somme.c new file mode 100644 index 0000000..4506089 --- /dev/null +++ b/semestre 2/informatique/td/1- exemples/signe_somme.c @@ -0,0 +1,17 @@ +#include + +int signeSomme(int a, int b){ + if (a > -b){ + return 1; + } else if (a == -b){ + return 0; + } + return -1; +} + +int main(){ + assert(signeSomme(2, -1) == 1); + assert(signeSomme(-1, 1) == 0); + assert(signeSomme(-2, 1) == -1); + return 0; +} -- cgit v1.2.3