Bonjour à vous tous. Je dois écrire une procédure qui retourne l’histogramme en pourcentages d'un tableau de répartitions t'en n catégories.
J'ai écris ça :
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
 
const nmax=1000;
type tableaunombres=array[1..nmax] of real;
 
 
procedure entreetableau(var t: tableaunombres; var n:integer);
var i: integer;
begin
write('Entrez le nombre de données : ');
readln(n);
for i:=1 to n do
  begin
    write(' La ',i,' ème donnée est: ');
    readln(t[i]);
  end;
end;
 
 
procedure normalisepourcentage(var t: tableaunombres; n:integer;var pourcent:tableaunombres);
var i:integer;c:real;
begin
c:=0;
for i:=1 to n do
    c:=c+t[i];
for i:=1 to n do
  pourcent[i]:=100*(t[i])/c;
end;
 
 
procedure histogramme(s:string;var t,pourcent:tableaunombres; n:integer);
var i,r,k:integer;w:char;
begin
for i:=1 to n do
t[i]:=pourcent[i];
for i:=1 to n do
  begin
    r:=trunc(t[i]);
    ord(s[0]):=r;
    for k:=1 to r do
    s[k]:=*;{erreur}
  end;
end;
 
 
var t,pourcent:tableaunombres; n,i:integer; c:real; s:string;
begin
entreetableau(t,n);
normalisepourcentage(t,n,pourcent);
histogramme(s,t,pourcent,n);
for i:=1 to n do
writeln(i,' ',s,' ',t[i]:10:1);
readln;
end.

et il me met illegal expression (là ou j'ai écrit en gras rouge) quand je compile.
Or je croyais qu'on pouvait mettre n'importe quel caractère dans une chaine.
Donc j'attends vos lumières.
merci