Смекни!
smekni.com

Разработка технологий повторения темы Логика высказываний (стр. 23 из 24)

N6: TMenuItem;

N7: TMenuItem;

N8: TMenuItem;

N9: TMenuItem;

Panel2: TPanel;

Panel1: TPanel;

Edit1: TEdit;

Label1: TLabel;

Image1: TImage;

Image2: TImage;

Image3: TImage;

Image4: TImage;

Image5: TImage;

Image6: TImage;

Image7: TImage;

Image9: TImage;

Image8: TImage;

Image10: TImage;

BitBtn1: TBitBtn;

Image11: TImage;

Image12: TImage;

Image13: TImage;

Label3: TLabel;

Label4: TLabel;

Edit2: TEdit;

Edit3: TEdit;

BitBtn2: TBitBtn;

Label2: TLabel;

Label5: TLabel;

Label6: TLabel;

Edit4: TEdit;

BitBtn3: TBitBtn;

Edit5: TEdit;

Image14: TImage;

N31: TMenuItem;

N10: TMenuItem;

N12: TMenuItem;

N13: TMenuItem;

N14: TMenuItem;

OpenDialog1: TOpenDialog;

N3: TMenuItem;

procedure Image2Click(Sender: TObject);

procedure Image3Click(Sender: TObject);

procedure Image7Click(Sender: TObject);

procedure Image4Click(Sender: TObject);

procedure Image5Click(Sender: TObject);

procedure Image1Click(Sender: TObject);

procedure Image6Click(Sender: TObject);

procedure Image9Click(Sender: TObject);

procedure Image8Click(Sender: TObject);

procedure Image10Click(Sender: TObject);

procedure FormShow(Sender: TObject);

procedure Image11Click(Sender: TObject);

procedure Image12Click(Sender: TObject);

procedure BitBtn2Click(Sender: TObject);

procedure BitBtn3Click(Sender: TObject);

procedure Image13Click(Sender: TObject);

procedure Edit5Change(Sender: TObject);

procedure BitBtn1Click(Sender: TObject);

procedure Image14Click(Sender: TObject);

procedure N4Click(Sender: TObject);

procedure N2Click(Sender: TObject);

procedure N11Click(Sender: TObject);

procedure N10Click(Sender: TObject);

procedure N12Click(Sender: TObject);

procedure N13Click(Sender: TObject);

procedure N14Click(Sender: TObject);

procedure N9Click(Sender: TObject);

procedure N3Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

n,k:integer;

s:array[1..5] of char ;

g:array[1..50] of integer;

implementation

uses Unit3, Unit2, Unit5;

{$R *.dfm}

procedure TForm1.Image2Click(Sender: TObject);

begin

If Form3.Visible=true then begin

Edit4.Text:=Edit4.Text+'v';

n:=n+1 ;

//Setlength(s,n);

s[n]:='v';

end

Else

Edit1.Text:=Edit1.Text+'v'

end;

procedure TForm1.Image3Click(Sender: TObject);

begin

If Form3.Visible=true then begin

Edit4.Text:=Edit4.Text+'&';

n:=n+1 ;

s[n]:='&';

end

Else

Form1.Edit1.Text:=Edit1.Text+'&'

end;

procedure TForm1.Image7Click(Sender: TObject);

begin

If Form3.Visible=true then begin

Edit4.Text:=Edit4.Text+'г';

n:=n+1 ;

s[n]:='г';

end

Else

Form1.Edit1.Text:=Edit1.Text+'г'

end;

procedure TForm1.Image4Click(Sender: TObject);

begin

If Form3.Visible=true then begin

Edit4.Text:=Edit4.Text+'~';

n:=n+1 ;

s[n]:='~';

end

Else

Form1.Edit1.Text:=Edit1.Text+'~'

end;

procedure TForm1.Image5Click(Sender: TObject);

begin

If Form3.Visible=true then begin

Edit4.Text:=Edit4.Text+'|';

n:=n+1 ;

s[n]:='|';

end

Else

Form1.Edit1.Text:=Edit1.Text+'|'

end;

procedure TForm1.Image1Click(Sender: TObject);

begin

If Form3.Visible=true then begin

Edit4.Text:=Edit4.Text+'->';

n:=n+1 ;

s[n]:='>';

end

Else

Form1.Edit1.Text:=Edit1.Text+'->'

end;

procedure TForm1.Image6Click(Sender: TObject);

begin

If Form3.Visible=true then begin

Edit4.Text:=Edit4.Text+'!';

n:=n+1 ;

s[n]:='!';

end

Else

Form1.Edit1.Text:=Edit1.Text+'!'

end;

procedure TForm1.Image9Click(Sender: TObject);

begin

Form1.Edit1.Text:=Edit1.Text+'('

end;

procedure TForm1.Image8Click(Sender: TObject);

begin

Form1.Edit1.Text:=Edit1.Text+')'

end;

procedure TForm1.Image10Click(Sender: TObject);

begin

If Form3.Visible=true then

begin

Edit4.Text:='';

n:=0;

end

Else

Form1.Edit1.Text:=''

end;

procedure TForm1.FormShow(Sender: TObject);

begin

n:=0;

end;

procedure TForm1.Image11Click(Sender: TObject);

begin

If Form3.Visible=true then begin

Edit4.Text:=Edit4.Text+'A';

n:=n+1 ;

s[n]:='A';

end

Else

Form1.Edit1.Text:=Edit1.Text+'A'

end;

procedure TForm1.Image12Click(Sender: TObject);

begin

If Form3.Visible=true then begin

Edit4.Text:=Edit4.Text+'B';

n:=n+1 ;

s[n]:='B';

end

Else

Form1.Edit1.Text:=Edit1.Text+'B'

end;

procedure TForm1.BitBtn2Click(Sender: TObject);

begin

Form3.Show;

k:=0

end;

procedure TForm1.BitBtn3Click(Sender: TObject);

var i,j:integer ;

Rez,t,h:boolean;

v:array[1..4] of boolean;

r:array[1..50] of boolean;

begin

k:=k+1;

Form3.StringGrid1.Cells[k+StrToInt(Edit2.Text),0]:=Edit4.Text;

Edit4.Text:='';

if k<= (StrToInt(Edit3.Text)-1) then

Label2.Caption:= 'Введите'+' '+Inttostr(k+1)+' '+'шаг';

//вычисление

For j:=1 to Form3.StringGrid1.RowCount-1 do

Begin

For i:=1 to StrToInt(Edit2.Text) do

If Form3.StringGrid1.Cells[i,j]='1' then v[i]:=true

else v[i]:=false;

For i:=1 to k do

If Form3.StringGrid1.Cells[StrToInt(Edit2.Text)+i,j]='1' then r[i]:=true

else r[i]:=false;

If ((s[1]='г') and ((s[2] in ['A'..'D'])or(s[2]='R')) and (n=2)) then

Begin

If s[2]='A' then t:=v[1]

else

If s[2]='B' then t:=v[2]

else

If s[2]='C' then t:=v[3]

else

If s[2]='D' then t:=v[4]

else

If (s[2]='R') then

For i:=1 to k+1 do

If g[2]=i then t:=r[i];

Rez:=(not(t));

end

else

If (((s[2] in ['A'..'D'])or(s[2]='R'))and ((s[5] in ['A'..'D'])or(s[5]='R')))

then

Begin

If s[2]='A' then t:=not(v[1])

else

If s[2]='B' then t:=not(v[2])

else

If s[2]='C' then t:=not(v[3])

else

If s[2]='D' then t:=not(v[4])

else

If (s[2]='R') then

For i:=1 to k+1 do

If g[2]=i then t:=not(r[i]);

If s[5]='A' then h:=not(v[1])

else

If s[5]='B' then h:=not(v[2])

else

If s[5]='C' then h:=not(v[3])

else

If s[5]='D' then h:=not(v[4])

else

If (s[5]='R') then

For i:=1 to k+1 do

If g[5]=i then h:=not(r[i]);

case s[3] of

'v': Rez:=(t or h);

'&': Rez:=(t and h);

'>': Rez:=(not(t) or h);

'~': Rez:=((not(t) or h)and(not(h) or t));

'|': Rez:=not(t and h);

'!': Rez:=not(t or h);

else

ShowMessage('Неправильно выделен шаг вычислений')

end

end

else

If (((s[1] in ['A'..'D'])or(s[1]='R'))and ((s[4] in ['A'..'D'])or(s[4]='R')))

then

Begin

If s[1]='A' then t:=v[1]

else

If s[1]='B' then t:=v[2]

else

If s[1]='C' then t:=v[3]

else

If s[1]='D' then t:=v[4]

else

If (s[1]='R') then

For i:=1 to k+1 do

If g[1]=i then t:=r[i];

If s[4]='A' then h:=not(v[1])

else

If s[4]='B' then h:=not(v[2])

else

If s[4]='C' then h:=not(v[3])

else

If s[4]='D' then h:=not(v[4])

else

If (s[4]='R') then

For i:=1 to k+1 do

If g[4]=i then h:=not(r[i]);

case s[2] of

'v': Rez:=(t or h);

'&': Rez:=(t and h);

'>': Rez:=(not(t) or h);

'~': Rez:=((not(t) or h)and(not(h) or t));

'|': Rez:=not(t and h);

'!': Rez:=not(t or h);

else

ShowMessage('Неправильно выделен шаг вычислений')

end

end

else

If (((s[2] in ['A'..'D'])or(s[2]='R'))and ((s[4] in ['A'..'D'])or(s[4]='R')))

then

Begin

If s[2]='A' then t:=not(v[1])

else

If s[2]='B' then t:=not(v[2])

else

If s[2]='C' then t:=not(v[3])

else

If s[2]='D' then t:=not(v[4])

else

If (s[2]='R') then

For i:=1 to k+1 do

If g[2]=i then t:=not(r[i]);

If s[4]='A' then h:=v[1]

else

If s[4]='B' then h:=v[2]

else

If s[4]='C' then h:=v[3]

else

If s[4]='D' then h:=v[4]

else

If (s[4]='R') then

For i:=1 to k+1 do

If g[4]=i then h:=r[i];

case s[3] of

'v': Rez:=(t or h);

'&': Rez:=(t and h);

'>': Rez:=(not(t) or h);

'~': Rez:=((not(t) or h)and(not(h) or t));

'|': Rez:=not(t and h);

'!': Rez:=not(t or h);

else

ShowMessage('Неправильно выделен шаг вычислений')

end

end

else

If (((s[1] in ['A'..'D'])or(s[1]='R'))and ((s[3] in ['A'..'D'])or(s[3]='R')))

then

Begin

If s[1]='A' then t:=v[1]

else

If s[1]='B' then t:=v[2]

else

If s[1]='C' then t:=v[3]

else

If s[1]='D' then t:=v[4]

else

If (s[1]='R') then

For i:=1 to k+1 do

If g[1]=i then t:=r[i];

If s[3]='A' then h:=v[1]

else

If s[3]='B' then h:=v[2]

else

If s[3]='C' then h:=v[3]

else

If s[3]='D' then h:=v[4]

else

If (s[3]='R') then

For i:=1 to k+1 do

If g[3]=i then h:=r[i];

case s[2] of

'v': Rez:=(t or h);

'&': Rez:=(t and h);

'>': Rez:=(not(t) or h);

'~': Rez:=((not(t) or h)and(not(h) or t));

'|': Rez:=not(t and h);

'!': Rez:=not(t or h);

else

ShowMessage('Неправильно выделен шаг вычислений')

end

end ;

If (Rez=True) then Form3.StringGrid1.Cells[k+strtoint(Edit2.Text),j]:='1'

else Form3.StringGrid1.Cells[k+strtoint(Edit2.Text),j]:='0';

End ;

n:=0

end;

procedure TForm1.Image13Click(Sender: TObject);

begin

If Form3.Visible=true then begin

Edit4.Text:=Edit4.Text+'C';

n:=n+1 ;

s[n]:='C';

end

Else

Form1.Edit1.Text:=Edit1.Text+'C'

end;

procedure TForm1.Edit5Change(Sender: TObject);

var i:integer;

begin

Edit4.Text:=Edit4.Text+'rez'+Edit5.Text;

n:=n+1 ;

For i:=1 to strtoint(Edit3.Text) do

if strtoint(Edit5.Text)=i

then begin s[n]:='R'; g[n]:=i end;

end;

procedure TForm1.BitBtn1Click(Sender: TObject);

begin

form2.Show;

end;

procedure TForm1.Image14Click(Sender: TObject);

begin

If Form3.Visible=true then begin

Edit4.Text:=Edit4.Text+'D';

n:=n+1 ;

s[n]:='D';

end

Else

Form1.Edit1.Text:=Edit1.Text+'D'

end;

procedure TForm1.N4Click(Sender: TObject);

begin

Close;

end;

procedure TForm1.N2Click(Sender: TObject);

var OpenDialog1:TOpenDialog;

MyFileName:AnsiString;

f:textfile;

formula:AnsiString;

begin

OpenDialog1:=TOpenDialog.Create(Form1);

if OpenDialog1.Execute then

Begin

MyFileName:=OpenDialog1.FileName;

Assignfile(F,MyFileName) ;

Reset( F);

ReadLn(F,formula);

Edit1.Text:=formula;

End

end;

procedure TForm1.N11Click(Sender: TObject);

begin

Form5.Show

end;

procedure TForm1.N10Click(Sender: TObject);

begin

Application.HelpFile := 'ВЫСКАЗЫВАНИЯ.hlp';

Application.HelpJump('TApplication_HelpJump');

end;

procedure TForm1.N12Click(Sender: TObject);

begin

Application.HelpFile := 'ОПЕРАЦИИ.hlp';

Application.HelpJump('TApplication_HelpJump');

end;

procedure TForm1.N13Click(Sender: TObject);

begin

Application.HelpFile := 'ДНФ И КНФ.hlp';

Application.HelpJump('TApplication_HelpJump');

end;

procedure TForm1.N14Click(Sender: TObject);

begin

Application.HelpFile := 'СДНФ.hlp';

Application.HelpJump('TApplication_HelpJump');

end;

procedure TForm1.N9Click(Sender: TObject);

begin

Application.HelpFile := 'ПРИМЕР.hlp';

Application.HelpJump('TApplication_HelpJump');

end;

procedure TForm1.N3Click(Sender: TObject);

begin

Application.HelpFile := 'РАВНОСИЛЬНОСТИ.hlp';

Application.HelpJump('TApplication_HelpJump');

end;

end.

unit Unit2;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, jpeg, ExtCtrls;

type

TForm2 = class(TForm)

Image1: TImage;

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form2: TForm2;

implementation

{$R *.dfm}

end.

unit Unit3;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, Grids, StdCtrls, Buttons, ExtCtrls;

type

TForm3 = class(TForm)

StringGrid1: TStringGrid;

Panel1: TPanel;

BitBtn1: TBitBtn;

Panel2: TPanel;

procedure FormShow(Sender: TObject);

procedure BitBtn1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form3: TForm3;

implementation

uses Unit2, Unit1, Unit4;

{$R *.dfm}

procedure TForm3.FormShow(Sender: TObject);

var k,s,i,j,d:integer;

F:textfile;

begin

StringGrid1.ColCount:=1+strtoint(Form1.Edit2.Text)+strtoint(Form1.Edit3.Text);

k:=StrToInt(Form1.Edit2.Text);

s:=2 ;

For i:=1 to k-1 do

s:=s*2;

StringGrid1.RowCount:=s+1;

If k=2 then begin AssignFile(F,'matr2.txt'); StringGrid1.Cells[1,0]:='A'; StringGrid1.Cells[2,0]:='B'; For i:=1 to 4 do StringGrid1.Cells[0,i]:=inttostr(i)end

else

If k=3 then begin AssignFile(F,'matr3.txt');StringGrid1.Cells[1,0]:='A'; StringGrid1.Cells[2,0]:='B';StringGrid1.Cells[3,0]:='C'; For i:=1 to 8 do StringGrid1.Cells[0,i]:=inttostr(i)end

else

If k=4 then begin AssignFile(F,'matr4.txt');StringGrid1.Cells[1,0]:='A'; StringGrid1.Cells[2,0]:='B';StringGrid1.Cells[3,0]:='C'; StringGrid1.Cells[4,0]:='D'; For i:=1 to 16 do StringGrid1.Cells[0,i]:=inttostr(i)end

Reset(F);

for i:=1 to s do begin

for j:=1 to k do

begin

Read(F,d);

StringGrid1.Cells[j,i]:=inttostr(d);

end;

readln(F) ;

end;

CloseFile(F)

end;

procedure TForm3.BitBtn1Click(Sender: TObject);

begin

Form4.Show;

end;

end.

unit Unit4;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, ExtCtrls;

type

TForm4 = class(TForm)

Panel1: TPanel;

Panel2: TPanel;

Edit1: TEdit;

Edit2: TEdit;

Label1: TLabel;

Label2: TLabel;

procedure FormShow(Sender: TObject);

private

{ Private declarations }

public