Цитата:
Сообщение от alexusankov
не представляет. с ней нет проблем
Код:
if Copy(listbox1.Items[0],1,1) = '-' then listbox1.Items.Insert(0,'+1');
if Copy(listbox1.Items[listbox1.Items.count - 1],1,1) = '+' then listbox1.Items.Add('-1440');
|
Странно, а по условию нужно добавлять числа 0 и -800
Вот, проверяй, вроде работает:
Код:
procedure TForm1.Button1Click(Sender: TObject);
var
i, i1, i2: Integer;
begin
ListBox1.Items.Text := '-15'#13'+35'#13'-42'#13'+78'#13'-116'#13'-182'#13'+350'#13'-360'#13'+620'#13'+630'#13'-700'#13'+730';
if StrToInt(ListBox1.Items[0]) < 0 then ListBox1.Items.Insert(0, '0');
if StrToInt(ListBox1.Items[ListBox1.Items.Count - 1]) >= 0 then ListBox1.Items.Add('-800');
i := 0;
while i < ListBox1.Items.Count - 1 do
begin
i1 := StrToInt(ListBox1.Items[i]);
i2 := StrToInt(ListBox1.Items[i + 1]);
if (i1 < 0) and (i2 < 0) then
begin
if Abs(i1 - i2) < 2 then
begin
ListBox1.Items.Delete(i);
end else
begin
ListBox1.Items.Insert(i + 1, '+' + IntToStr(2 - i1));
Inc(i);
end;
end else
if (i1 >= 0) and (i2 >= 0) then
begin
if Abs(i1 - i2) < 2 then
begin
ListBox1.Items.Delete(i);
end else
begin
ListBox1.Items.Insert(i + 1, IntToStr(2 - i2));
Inc(i);
end;
end else
begin
Inc(i);
end;
end;
end;
Осталось только добавление в ListBox2 и ListBox3 сделать.
Цитата:
Сообщение от alexusankov
что делать с остальным ума не приложу
З.ы. Кажись нужно сувать значение в переменную так, чтобы в а1 оказалось предыдущее значение а2. Мне кажется это правильный путь. И флаг добавить. Точно, буду думать.
Час.
|
Ок. Потом сравним результаты
