hola ñuño,
el error salta cuando se pulsa este boton..
Código Delphi
[-]procedure TForm1.Button4Click(Sender: TObject);
var
i, j, p : Integer;
ModaCount : Array[0..5] of Integer;
AModa : Array[0..5] of TModa;
b : Boolean;
begin
FillChar(ModaCount,Sizeof(ModaCount),0);
for i := 0 to lista.Items.Count - 1 do
begin
for j := 0 to lista.Items.Item[i].SubItems.Count - 1 do
begin
p := StrToInt(lista.Items.Item[i].SubItems.Strings[j]);
ModaCount[p] := ModaCount[p] + 1;
end;
end;
FillChar(AModa,Sizeof(AModa),-1);
for i := Low(AModa) to High(AModa) do
for j := Low(ModaCount) to High(ModaCount) do
begin
if AModa[i].Count < ModaCount[j] then
begin
for p := 0 to 5 do
if (AModa[p].Number = j) then
b := True;
if not b then
begin
AModa[i].Number := j;
AModa[i].Count := ModaCount[j];
end;
b := False;
end;
end;
for i:= 0 to 6 do
begin
if (AModa[i].Count <> 0) then
ShowMessage(Format('El %s número es %d con %d ocurrencias',[Secuencia[i],AModa[i].Number,AModa[i].Count]));
end;
end;
Un saludo.