Code:typedef struct AList { int no1; int no2; int no3; int no4; int no5; } TAList; typedef TAList* PAList; TList * ResultList; void __fastcall TForm1::FormCreate(TObject *Sender) { randomize(); ResultList = new TList; } void __fastcall TForm1::Button1Click(TObject *Sender) { DWORD StartTime,EndTime,LastTime; StartTime=GetTickCount(); // for(int i=0;i<100000;i++) { PAList AStruct; AStruct = new TAList; AStruct->no1=random(10); AStruct->no2=random(10); AStruct->no3=random(10); AStruct->no4=random(10); AStruct->no5=random(10); ResultList->Add(AStruct); } for(int i=0;i<Form1->ResultList->Count-1;i++) { PAList AStruct; AStruct = new TAList; AStruct = (PAList) ResultList->Items[i]; for(int j=i+1;j<Form1->ResultList->Count;j++) { PAList BStruct; BStruct = new TAList; BStruct = (PAList) ResultList->Items[j]; int iSame=0; if(AStruct->no1==(BStruct->no1+1)) continue; if(AStruct->no2==(BStruct->no2+1)) continue; if(AStruct->no3==(BStruct->no3+1)) continue; if(AStruct->no4==(BStruct->no4+1)) continue; if(AStruct->no5==(BStruct->no5+1)) continue; ResultList->Delete(j);j--; delete BStruct; } } EndTime=GetTickCount(); LastTime=EndTime-StartTime; Application->MessageBoxA(IntToStr(LastTime).c_str(),"time used",MB_ICONEXCLAMATION); } void __fastcall TForm1::FormDestroy(TObject *Sender) { if(ResultList->Count>0) for(int i=ResultList->Count-1;i<-1;i--) { PAList AStruct; AStruct = new TAList; AStruct =(PAList) ResultList->Items[i]; ResultList->Delete(i); delete[] AStruct; } }