Salut
Je viens de faire un programme d'intelligence artificielle qui devine le nombre auquel vous avez pensé en donnant un indice +, - ou = en donnant le nombre d'essais.
J'ai fait ceci mais le message s'affiche 3 fois et le calcul reste constant après 7 indices
svp aidez-moi à le corriger.
Merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
program jeux ;
 
uses wincrt;
 
var
 
c:char;
b:integer;
 
procedure lecture (var c:char;var b:integer);
begin
	repeat
   writeln('donnez-moi votre indice +,- ou = :');
		read(c);
	until c in ['-','+','='];
end;
 
 
 
procedure test (c:char;var b:integer);
var
 
x,i:integer;
begin
 
  b:=50;     x:=50;
 
writeln(b);
 
lecture(c,b);
 
i := 1;
 
if (c = '=') then
 
begin
 
writeln(' jai obtenu la solution en 1 coups!');
 
end
		else
		begin
				repeat
			b:= b div 2	;
			i := i +1 ;
			if (c = '+') then
			begin
 
			x := x + b ;
			writeln(x);
			lecture(c,b);
 
			end
 
			else
			begin
 
			x := x - b;
			writeln(x);
			lecture(c,b);
 
			end;
 
 
				until (c = '=');
writeln('j ai obtenu la solution en ',i,' coups!');
end;
end;
begin
test(c,b);
end.