Start tp5; add min-max

This commit is contained in:
flyingscorpio@pinebookpro 2021-11-29 08:30:51 +01:00
parent 454b7e8dc5
commit 9b2bd53a75
2 changed files with 44 additions and 0 deletions

View file

@ -0,0 +1,11 @@
CFLAGS=-lm
C_FILES=$(shell find . -name '*.*')
TARGETS=$(notdir $(basename ${C_FILES}))
all: ${TARGETS}
@for target in ${TARGETS}; do \
grep -q $${target} ../../.gitignore || echo $${target} >> ../../.gitignore; \
done
clean:
rm -f ${TARGETS}

View file

@ -0,0 +1,33 @@
/* Minimum, maximum */
#include <stdio.h>
#include <stdlib.h>
int min(int, int);
int max(int, int);
int main() {
int a, b;
a = 12;
b = 9;
printf("Le min de %d et %d est %d\n", a, b, min(a, b));
printf("Le max de %d et %d est %d\n", a, b, max(a, b));
return 0;
}
int min(int a, int b) {
if (a <= b) {
return a;
}
return b;
}
int max(int a, int b) {
if (a >= b) {
return a;
}
return b;
}