Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
PZ_DP_2012_chast_2.docx
Скачиваний:
3
Добавлен:
26.09.2019
Размер:
302.12 Кб
Скачать

Implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);

begin

mmo2.clear;

SG.Cells[0,0]:='X=' ;

SG.Cells[0,1]:='Y=' ;

SG.Options:=SG.Options+[goEditing]

end;

function TForm1.Cleaner(S: String): String;

var

I:integer;

BackStr : string;

begin

BackStr:='';

//Снос пробелов

for i:=1 to Length(S) do

begin

if(S[i]<>' ') then

BackStr:=BackStr+S[i];

end;

Cleaner:=BackStr;

//mmo2.Lines.Add(BackStr);

end;

function TForm1.DelF(S,D:string): String;

var

I,h,j,l,k,elem,n,m:integer;

Preo, Temp, Res : string;

nextS,HB,Go:Boolean;

Dif:Char;

BigElenent : Array of string;

HeaderPer : Array of Char;

NumerikArray : Array of Real;

ElementArray : Array of Array of string;

DataPer : Array of Array of Integer;

begin

Dif:=D[1];

//mmo2.Lines.Add('****start');

//(x+z)^2-y^2-1 // x^2-y^2-1 { y*(x-1)-1 x^2-y^2-1 }

Temp:=S;

for i:=Length(S) downto 1 do

if (S[i]=Dif) then

begin

Delete(s, i, 1);

Insert('('+Dif+'+z)',S,i);

end;

//mmo2.Lines.Add('1:'+S+''+Temp+')');

S:=S+'-('+Temp+')';

S:=Cleaner(S);

S:=Stepner(S);

S:=Preobr(S);

S:=ScoberU(S);

//mmo2.Lines.Add('...5:'+S);

S:=Sokr(S);

//mmo2.Lines.Add('...6:'+S);

while(Length(S)<>Length(Sokr(S)))do

begin

S:=Preobr(S);

S:=ScoberU(S);

S:=Sokr(S);

//mmo2.Lines.Add('...X:'+S);

end;

//mmo2.Lines.Add(s);

Go:=false;nextS:=False;HB:=false;

i:=0;h:=0;j:=0;l:=0;k:=0;elem:=0;n:=0;m:=0;

Preo:=''; Temp:=''; Res:='';

SetLength( BigElenent, 0); SetLength( HeaderPer, 0);

SetLength( NumerikArray, 0);SetLength( ElementArray, 0);SetLength( DataPer, 0);

for i:=1 to Length(S) do

begin

if((S[1]<>'(') and (S[Length(S)]<>')')) then // (-3.1-4.333+2.2*x+4.25*x)

S:='('+S+')';

if(S[i]='(')then

begin

nextS:=True;

for j:=i+1 to Length(S)-1 do

begin

if (s[j+1]='(') then

begin

nextS:=false;

Break;

//mmo2.Lines.Add(IntToStr(j));

end;

if (s[j+1]=')')then

Break;

end;

If(nextS)then

begin

//Go:=True;

//ShowMessage('OK');

Preo:='';

//mmo2.Lines.Add(Copy(S,i+1,j-i));

Preo:=Copy(S,i+1,j-i);

Delete(S,i,j-i+2); //4+(3*х-2*х)-12

//mmo2.Lines.Add('D:'+s);

If(not isPm(Preo[1]))then

Preo:='+'+Preo;

l:=Length(Preo);

k:=0;

for j:=Length(Preo) downto 1 do

If isPm(Preo[j]) then

begin

SetLength(BigElenent, k+1);

BigElenent[k]:=Copy(Preo, j, l-j+1);

k:=k+1;

l:=j-1;

end;

{for j:=0 to High(BigElenent) do

mmo2.Lines.Add(BigElenent[j]); }

SetLength(NumerikArray, High(BigElenent)+1);

SetLength(ElementArray, High(BigElenent)+1);

SetLength(HeaderPer, 0);

for j:=0 to High(BigElenent) do

begin

l:=Length(BigElenent[j]);

k:=0;

elem:=0;

if(BigElenent[j][1]='-')then

NumerikArray[j]:=-1

else

NumerikArray[j]:=1;

for h:=Length(BigElenent[j]) downto 1 do

begin

if((h=1)or(BigElenent[j][h]='*')) then

begin

if(isNumber(BigElenent[j][h+1]))then

begin

//mmo2.Lines.Add(Copy(BigElenent[j], h+1, l-h)); // 3*5*x-x*3+x*y = 12*x+x*y

NumerikArray[j]:=NumerikArray[j]*StrToFloat(Copy(BigElenent[j], h+1, l-h));

end

else

begin

SetLength(ElementArray[j], elem+1);

ElementArray[j][elem]:=Copy(BigElenent[j], h+1, l-h);

elem:=elem+1;

end;

//mmo2.Lines.Add(Copy(BigElenent[j], h+1, l-h));

l:=h-1;

end;

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]