26 lines
574 B
C
26 lines
574 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
void rec(uint a, uint b, uint x) {
|
|
uint guess = (a + b) / 2;
|
|
printf("Ordinateur : %d\n", guess);
|
|
if (guess == x) {
|
|
printf("Arbitre : C'est bon !\n");
|
|
} else if (guess < x) {
|
|
printf("Arbitre : C'est plus !\n");
|
|
return rec(guess, b, x);
|
|
} else {
|
|
printf("Arbitre : C'est moins !\n");
|
|
return rec(a, guess, x);
|
|
}
|
|
}
|
|
|
|
void f(uint n, uint x) { return rec(0, n, x); }
|
|
|
|
int main() {
|
|
uint x = 4329;
|
|
uint n = 32413524;
|
|
printf("x = %d et n = %d\n", x, n);
|
|
f(n, x);
|
|
}
|