Код:
procedure TForm1.Button1Click(Sender: TObject);
var i,j,n:integer;
a:array of integer;
begin
stringgrid2.ColCount:=0;
n:=stringgrid1.ColCount;
setLength(a,n);
try
for i:=0 to n-1 do
a[i]:=StrToInt(stringgrid1.Cells[i,0]);
except
ShowMessage('введите число');
exit;
end;
for i:=0 to n-2 do
if ((a[i] mod 2)<>0) and ((a[i+1] mod 2)=0) then begin
for j:=0 to n-1 do
if a[j]>0 then begin
StringGrid2.Cells[StringGrid2.ColCount-1,0]:=IntToStr(a[j]);
StringGrid2.ColCount:=StringGrid2.ColCount+1;
end;
StringGrid2.ColCount:=StringGrid2.ColCount-1;
exit;
end;
for j:=0 to n-1 do
if a[j]<0 then begin
StringGrid2.Cells[StringGrid2.ColCount-1,0]:=IntToStr(a[j]);
StringGrid2.ColCount:=StringGrid2.ColCount+1;
end;
StringGrid2.ColCount:=StringGrid2.ColCount-1;
end;
вот что-то типа тоакого у тебя должно получится