17-02-2021, 02:23 PM
السلام عليكم
حل على السريع... ليس أنيق لكنه يفي بالغرض.
كود :
Var
NN: Boolean;
Max, i,j,k,m : integer;
St: String;
begin
ListBox1.Clear;
Max:= StringGrid1.RowCount-1;
For i:=1 to Max Do begin
K:=1;NN:=False;
For j:=i+1 to Max Do
if StringGrid1.Cells[1, i]=StringGrid1.Cells[1, j] then inc(k);
if K>1 then begin
For m:=0 to ListBox1.Items.Count-1 do
if copy(ListBox1.Items[m],1,pos('=',ListBox1.Items[m])-1)=StringGrid1.Cells[1,i] then NN:=True;
if not NN then ListBox1.Items.Add(StringGrid1.Cells[1,i]+'='+IntToStr(k));
end;
end;
//////////////////////////////////////
ListBox2.Clear;
For i:=1 to Max Do begin
K:=1;NN:=False;
For j:=i+1 to Max Do
if StringGrid1.Cells[3, i]=StringGrid1.Cells[3, j] then inc(k);
if K>1 then begin
For m:=0 to ListBox2.Items.Count-1 do
if copy(ListBox2.Items[m],1,pos('=',ListBox2.Items[m])-1)=StringGrid1.Cells[3,i] then NN:=True;
if not NN then ListBox2.Items.Add(StringGrid1.Cells[3,i]+'='+IntToStr(k));
end;
end;
end;
رَبَّنَا اغْفِرْ لِي وَلِوَالِدَيَّ وَلِلْمُؤْمِنِينَ يَوْمَ يَقُومُ الْحِسَابُ


![[-]](https://delphi4arab.net/forum/D4A2020/collapse.png)