Во избежание того, что забивающие не забьют дело вот такой модуль проверки:
![Проверка списка на целостность средствами Delphi Проверка списка на целостность средствами Delphi]()
С уважением, Сургай Владимир.
procedure TForm4.celosn(SP:TStrings);
Var
clas,tmp:TStrings;
civ:Boolean;
i,j,c:Integer;
tm,t:String;
begin
civ := True; //Chenge in Rozpodil
clas := TstringList.Create;
tmp := TstringList.Create;
clas.Add('а'); clas.Add('в'); clas.Add('з');
clas.Add('к'); clas.Add('н'); clas.Add('о');
clas.Add('п'); clas.Add('с');
tmp.Clear;
//Выбор стандартных дел без приставок
for i := 0 to Sp.Count - 1 do
begin
tm := sp.Strings[i];
if ((tm[1] = '1') or (tm[1] = '2') or (tm[1] = '3') or (tm[1] = '4') or
(tm[1] = '5') or (tm[1] = '6') or (tm[1] = '7') or (tm[1] = '8') or
(tm[1] = '9')) then tmp.Add(tm);
end;
//Сортировка стандартных дел
for i := 0 to tmp.Count - 1 do
for j := 0 to tmp.Count - 2 do
begin
tm := tmp.Strings[j];
if StrToInt(tm) > StrToInt(tmp.Strings[j 1]) then
begin
tmp.Strings[j] := tmp.Strings[j 1];
tmp.Strings[j 1] := tm;
end;
end;
//Проверка целосности
lbN.Items.Clear;//чистим список отсутствующих дел
for i := 0 to tmp.Count - 2 do
if StrToInt(tmp.Strings[i 1])-StrToInt(tmp.Strings[i]) > 1 then
for j := StrToInt(tmp.Strings[i]) 1 to StrToInt(tmp.Strings[i 1])-1 do
lbN.Items.Add(IntToStr(j));
//Указания максимума
Label9.Caption := '2-' tmp.Strings[tmp.Count - 1];
//Сортировка дел
for c := 0 to clas.Count - 1 do
begin
tmp.Clear;
//Выбор дел по слассам
for i := 0 to Sp.Count - 1 do
begin
tm := sp.Strings[i]; t := '';
if tm[1] = clas.Strings[c] then
begin
for j := 3 to length(tm) do
t := t tm[j];
tmp.Add(t);
end;
end;
//Сортировка стандартных дел
for i := 0 to tmp.Count - 1 do
for j := 0 to tmp.Count - 2 do
begin
tm := tmp.Strings[j];
if StrToInt(tm) > StrToInt(tmp.Strings[j 1]) then
begin
tmp.Strings[j] := tmp.Strings[j 1];
tmp.Strings[j 1] := tm;
end;
end;
//Проверка целосности
for i := 0 to tmp.Count - 2 do
if StrToInt(tmp.Strings[i 1])-StrToInt(tmp.Strings[i]) > 1 then
for j := StrToInt(tmp.Strings[i]) 1 to StrToInt(tmp.Strings[i 1])-1 do
lbN.Items.Add('2-' clas.Strings[c] '-' IntToStr(j));
if tmp.Count > 0 then
Label9.Caption := Label9.Caption #13#10 '2-' clas.Strings[c] '-'
tmp.Strings[tmp.Count - 1];
end;
if lbN.Count>0 then Label10.Caption:='Кількість справ: ' IntToStr(lbN.Count);
end;
Var
clas,tmp:TStrings;
civ:Boolean;
i,j,c:Integer;
tm,t:String;
begin
civ := True; //Chenge in Rozpodil
clas := TstringList.Create;
tmp := TstringList.Create;
clas.Add('а'); clas.Add('в'); clas.Add('з');
clas.Add('к'); clas.Add('н'); clas.Add('о');
clas.Add('п'); clas.Add('с');
tmp.Clear;
//Выбор стандартных дел без приставок
for i := 0 to Sp.Count - 1 do
begin
tm := sp.Strings[i];
if ((tm[1] = '1') or (tm[1] = '2') or (tm[1] = '3') or (tm[1] = '4') or
(tm[1] = '5') or (tm[1] = '6') or (tm[1] = '7') or (tm[1] = '8') or
(tm[1] = '9')) then tmp.Add(tm);
end;
//Сортировка стандартных дел
for i := 0 to tmp.Count - 1 do
for j := 0 to tmp.Count - 2 do
begin
tm := tmp.Strings[j];
if StrToInt(tm) > StrToInt(tmp.Strings[j 1]) then
begin
tmp.Strings[j] := tmp.Strings[j 1];
tmp.Strings[j 1] := tm;
end;
end;
//Проверка целосности
lbN.Items.Clear;//чистим список отсутствующих дел
for i := 0 to tmp.Count - 2 do
if StrToInt(tmp.Strings[i 1])-StrToInt(tmp.Strings[i]) > 1 then
for j := StrToInt(tmp.Strings[i]) 1 to StrToInt(tmp.Strings[i 1])-1 do
lbN.Items.Add(IntToStr(j));
//Указания максимума
Label9.Caption := '2-' tmp.Strings[tmp.Count - 1];
//Сортировка дел
for c := 0 to clas.Count - 1 do
begin
tmp.Clear;
//Выбор дел по слассам
for i := 0 to Sp.Count - 1 do
begin
tm := sp.Strings[i]; t := '';
if tm[1] = clas.Strings[c] then
begin
for j := 3 to length(tm) do
t := t tm[j];
tmp.Add(t);
end;
end;
//Сортировка стандартных дел
for i := 0 to tmp.Count - 1 do
for j := 0 to tmp.Count - 2 do
begin
tm := tmp.Strings[j];
if StrToInt(tm) > StrToInt(tmp.Strings[j 1]) then
begin
tmp.Strings[j] := tmp.Strings[j 1];
tmp.Strings[j 1] := tm;
end;
end;
//Проверка целосности
for i := 0 to tmp.Count - 2 do
if StrToInt(tmp.Strings[i 1])-StrToInt(tmp.Strings[i]) > 1 then
for j := StrToInt(tmp.Strings[i]) 1 to StrToInt(tmp.Strings[i 1])-1 do
lbN.Items.Add('2-' clas.Strings[c] '-' IntToStr(j));
if tmp.Count > 0 then
Label9.Caption := Label9.Caption #13#10 '2-' clas.Strings[c] '-'
tmp.Strings[tmp.Count - 1];
end;
if lbN.Count>0 then Label10.Caption:='Кількість справ: ' IntToStr(lbN.Count);
end;

С уважением, Сургай Владимир.