aboutsummaryrefslogtreecommitdiff
path: root/semestre 2/informatique/td/1- exemples/signe_somme.c
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <anhgelus@anhgelus.world>2025-01-31 15:39:30 +0100
committerAnhgelus Morhtuuzh <anhgelus@anhgelus.world>2025-01-31 15:39:30 +0100
commitd7c69934248f3fab4988c0d37c11feba25d653b8 (patch)
tree6c396257cb21374e13a26b8f78c05353806220bc /semestre 2/informatique/td/1- exemples/signe_somme.c
parented631f52ee7af474625e37c6855c7c55903317fc (diff)
Ajout du début du deuxième semestre
Diffstat (limited to 'semestre 2/informatique/td/1- exemples/signe_somme.c')
-rw-r--r--semestre 2/informatique/td/1- exemples/signe_somme.c17
1 files changed, 17 insertions, 0 deletions
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 <assert.h>
+
+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;
+}