Salut les amis ;p.
Je veux créer un programme qui lie 3 entiers puis affiche un histogramme
Exemple:
x1=2
x2=6
x3=1
Le programme affiche

*B*
*B*
*B*
*B*
AB*
ABC


Aidez moi SVP
voila mon code source, je crois qu'il marche mais je ne sais pas ou est le problème


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
program ex1;
uses wincrt;
var
x1,x2,x3,i,j,max:integer;
tab:array[1..50,1..50]of char;
 
begin
writeln('Saisir X1');
readln(x1);
writeln('Saisir X2');
readln(x2);
writeln('Saisir X3');
readln(x3);
max:=x1;
if  x2>max then
max:=x2
else
if x3>max then
max:=x3;
 
for i:= 1 to 3 do
begin
for j:= 1 to max do
begin
tab[j,i]:='*'
end;
end;
 
for i:= max to 1 do
begin
if X1>0 then
Tab[i,1]:='A';
X1:=x1-1
end ;
 
for i:= max to 1 do
if X2>0 then
Tab[i,2]:='B';
x2:=x2-1 ;
 
 
for i:= max to 1 do
if X3>0 then
Tab[i,3]:='C';
x3:=x3-1;}
 
for i := 1 to max do
begin
for j := 1 to 3 do
begin
write(tab[i,j])
end;
writeln
 
end;
end.
Le probable a mon avis c'est dans le boucle pour

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
program ex1;
uses wincrt;
var
x1,x2,x3,i,j,max:integer;
tab:array[1..50,1..50]of char;
 
begin
writeln('Saisir X1');
readln(x1);
writeln('Saisir X2');
readln(x2);
writeln('Saisir X3');
readln(x3);
max:=x1;
if  x2>max then
max:=x2
else
if x3>max then
max:=x3;
 
for i:= 1 to 3 do
begin
for j:= 1 to max do
begin
tab[j,i]:=' '
end;
end;
 
for i:= max to 1 do
begin
if X1>0 then
Tab[i,1]:='A';
X1:=x1-1
end ;
 
for i:= max to 1 do
if X2>0 then
Tab[i,2]:='B';
x2:=x2-1 ;
 
 
for i:= max to 1 do
if X3>0 then
Tab[i,3]:='C';
x3:=x3-1;}
 
for i := 1 to max do
begin
for j := 1 to 3 do
begin
write(tab[i,j])
end;
writeln
 
end;
end.
Merci d'avance