Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Диплом.doc
Скачиваний:
0
Добавлен:
01.05.2025
Размер:
1.88 Mб
Скачать

Список используемых источников и литературы

        1. Дмитрий О. Delphi. Профессиональное программирование Builder [Текст] /. О. Дмитрий – СПб.: Символ-плюс, 2006. – 1056 с.

        2. Климов Л.М. основы программирование Delphi. Решение типовых задач. Самоучитель [Текст] /. Л.М. Климов – Москва.: КУДИЦ-образ, 2006. – 480 с.

        3. Фаронов В.В. Система программирования Delphi Builder [Текст] /. – СПб.: БХВ-Петербург, 2003. – 912 с.

        4. Троелсен А. Программирвоание на языке Delphi 2008 [Текст] / А. Троелсен - : APRESS, 2008. - 1400 с.

        5. Дейтел, Х. М. Как программировать для Internet и WWW. Х. М. Дейтел, П. Дж. Дейтел, Т. Р. Нието. Пер. с англ. [Текст] / – М.: ЗАО «Издательство БИНОМ», 2006 г. – 1184 с.

        6. Финогенов, К.Г. WIN32 Основы программирования[Текст] / К.Г. Финогенов М.: Диалог - МИФИ, 2006. – 416 с.

        7. Шлее М. Qt4. Профессиональное программирование [Текст] / М. Шлее.- СПб.: БХВ-Петербург, 2007. – 880 с.

        8. Владимир Ш. Delphi в примерах [Текст] / Ш.Владимир- Спб.: .: БХВ-Петербург, 2006. –528 с.

        9. Рубанцев, В. Большой самоучитель Delphi XE3 [Текст]/ В. Рубанцев- M.: Я+R, 2012.

        10. Юрий М. Использование Object Pascal Специальное издание [Текст] / М. Юрий.– М.: Издательский дом «Вильямс», 2006 г. – 628 с.

Приложение а

Программный код модуля «Решение СЛАУ методом Гаусса»

unit Unit1;

interface

uses

Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,

Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Imaging.pngimage,

Vcl.ExtCtrls, unit2, math;

type

TForm1 = class(TForm)

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

Label7: TLabel;

Label8: TLabel;

Label9: TLabel;

Label10: TLabel;

Label11: TLabel;

Label12: TLabel;

Label13: TLabel;

Label14: TLabel;

Label15: TLabel;

Label16: TLabel;

Image1: TImage;

Edit1: TEdit;

Edit2: TEdit;

Edit3: TEdit;

Edit4: TEdit;

Edit5: TEdit;

Edit6: TEdit;

Edit7: TEdit;

Edit8: TEdit;

Edit9: TEdit;

Edit10: TEdit;

Edit11: TEdit;

Edit12: TEdit;

Edit13: TEdit;

Edit14: TEdit;

Edit15: TEdit;

Edit16: TEdit;

Edit17: TEdit;

Edit18: TEdit;

Edit19: TEdit;

Edit20: TEdit;

Button1: TButton;

Label17: TLabel;

Label18: TLabel;

Label19: TLabel;

procedure Button1Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure Button3Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

const razm=4;

var

f1l,f1t:integer;

f2l,f2t:integer;

Edit: array[1..razm*razm+razm] of TEdit;

m: array[1..razm, 1..razm+1] of extended;

n: array[1..razm, 1..razm+1] of extended;

a:integer=0;

implementation

{$R *.dfm}

procedure posform2;

var

l,t:integer;

begin

l:=form1.Left;

t:=form1.Top;

l:=l+form1.Width;

form2.left:=l+10;

form2.top:=t;

end;

procedure clear;

var

i,j:integer;

begin

form2.memo1.Clear;

a:=0;

for i := 1 to razm do

for j := 1 to razm+1 do

begin

m[i,j]:=0;

n[i,j]:=0;

end;

end;

procedure pl;

var

i:integer;

begin

for i := 1 to razm+2 do

begin

form2.memo1.Lines.Add('');

end;

end;

procedure SRToMassN;

var

z,x:integer;

begin

for z := 1 to razm do

begin

for x := 1 to razm+1 do

begin

n[z,x]:=simpleroundto(n[z,x],-2)

end;

end;

end;

procedure EditToEditMass;

var

z: integer;

begin

for z := 1 to razm*razm+razm do

begin

Edit[z]:=TEdit(Form1.FindComponent('Edit'+IntToStr(z)));

end;

end;

procedure EditToMassM;

var

i,j: integer;

y: integer;

begin

for j := 0 to razm-1 do

for i := 1 to razm+1 do

begin

y:=j*(razm+1)+i;

m[j+1,i]:=strtofloat(edit[y].text);

end;

end;

procedure MassNToEdit;

var

i,j: integer;

y: integer;

begin

for j := 0 to razm-1 do

for i := 1 to razm+1 do

begin

y:=j*(razm+1)+i;

TEdit(Form1.FindComponent('Edit'+IntToStr(y+22))).text:=floattostr(n[j+1,i]);

end;

end;

procedure MassMToMassN;

var

i,j: integer;

begin

for j := 1 to razm do

for i := 1 to razm+1 do

begin

n[j,i]:=m[j,i];

end;

end;

procedure MassNToMassM;

var

i,j: integer;

begin

for j := 1 to razm do

for i := 1 to razm+1 do

begin

m[j,i]:=n[j,i];

end;

end;

procedure TForm1.Button1Click(Sender: TObject);

var

j,i,o:integer;

k:extended;

line,p:string;

q,r,b:integer;

c: array[1..razm] of extended;

e,w:extended;

h,v:integer;

begin

clear;

EditToMassM;

for o := 0 to razm-1 do

begin

pl;

for j := razm downto 1 do

begin

for i := 1 to razm+1 do

begin

if j<=razm-o then

begin

if (m[razm-o+1,o]<0) and (m[j,o]<0 ) or (m[razm-o+1,o]>0) and (m[j,o]>0 ) then

begin

k:=(-1)*m[j,o]/m[razm-o+1,o];

end else k:=abs(m[j,o]/m[razm-o+1,o]);

begin

n[j,i]:=m[razm-o+1,i]*k+m[j,i];

end;

end else n[j,i]:=m[j,i];

for h := 1 to 8-(length(floattostr(simpleroundto(n[j,i],-3)))) do

begin

p:=p+' ';

end;

line:=line+' '+floattostr(simpleroundto(n[j,i],-1))+p;

p:='';

end;

for h := 1 to 41-(length(line)) do

begin

p:=p+' ';

end;

form2.memo1.Lines[j+a]:=' |'+line+p+'|';

p:='';

line:='';

end;

a:=a+razm+2;

form2.memo1.Lines[a-(razm+2)]:=inttostr(o+1)+')'+' Этап';

MassNToEdit;

MassNToMassM;

end;

for q := 1 to razm do

begin

e:=0;

for r := 1 to q-1 do

begin

e:=e+c[r]*m[q,razm-r+1];

end;

w:=(m[q,razm+1]-e)/m[q,razm-q+1];

c[q]:=w;

form2.memo1.Lines.Add('');

form2.memo1.Lines[razm*(razm+2)]:=' |Корни СЛАУ|';

for v := 1 to razm do

begin

form2.memo1.Lines[razm*(razm+2)+v]:=' x'+inttostr(v)+' = '+floattostr(simpleroundto(c[v],-3));

end;

end;

for b := 1 to razm do

begin

TEdit(Form1.FindComponent('Edit'+IntToStr(b+42))).text:=floattostr(c[b]);

end;

posform2;

form2.show;

end;

procedure TForm1.FormCreate(Sender: TObject);

begin

EditToEditMass;

EditToMassM;

MassMtoMassN;

end;

end.

Программный код модуля «Решение задач ЛП геометрическим методом»

unit Unit1;

interface

uses

Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,

Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls,

VCLTee.TeEngine, VCLTee.TeeProcs, VCLTee.Chart, VCLTee.Series, math;

type

TForm1 = class(TForm)

Edit2: TEdit;

Edit3: TEdit;

Edit1: TEdit;

Edit4: TEdit;

Edit5: TEdit;

Edit6: TEdit;

Edit7: TEdit;

Edit8: TEdit;

ComboBox1: TComboBox;

ComboBox2: TComboBox;

Chart1: TChart;

Button1: TButton;

ComboBox3: TComboBox;

Button3: TButton;

Label1: TLabel;

Label2: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

Label7: TLabel;

Label3: TLabel;

Label20: TLabel;

Label21: TLabel;

Label8: TLabel;

Label9: TLabel;

Label10: TLabel;

Label11: TLabel;

Label12: TLabel;

Label13: TLabel;

Memo1: TMemo;

Button4: TButton;

Label14: TLabel;

Label15: TLabel;

Label16: TLabel;

Edit10: TEdit;

Edit11: TEdit;

Edit12: TEdit;

Edit13: TEdit;

Edit14: TEdit;

Edit15: TEdit;

Edit16: TEdit;

Edit17: TEdit;

Edit18: TEdit;

Label17: TLabel;

Edit19: TEdit;

Edit20: TEdit;

Label18: TLabel;

Label19: TLabel;

Label22: TLabel;

Label23: TLabel;

Label24: TLabel;

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure ComboBox2CloseUp(Sender: TObject);

procedure ComboBox1CloseUp(Sender: TObject);

procedure Button4Click(Sender: TObject);

procedure Edit19Click(Sender: TObject);

procedure Edit20Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.dfm}

var

b,v1,v2,u1:bool;

aa:integer=0;

x:integer=0;

const

razm=2;

p=' ';

procedure pl;

var

i:integer;

o:integer;

begin

o:=razm+2;

for i := 1 to o do

begin

form1.memo1.Lines.Add('');

end;

aa:=aa+o;

x:=x+1;

end;

function pp(q:string):string;

begin

result:=p+q+p;

end;

procedure TForm1.Button1Click(Sender: TObject);

var

i, j, kum: Integer;

s, t: TLineSeries;

a,b:integer;

begin

chart1.ClearChart;

chart1.View3D:=false;

chart1.Color:=clWhite;

if edit19.Text='' then

begin

edit19.Text:='-1000';

if edit20.Text='' then

begin

edit20.Text:='1000'

end else b:=strtoint(edit20.Text);

end else

begin

a:=strtoint(edit19.Text);

if edit20.Text='' then b:=1000 else b:=strtoint(edit20.Text);

end;

with Chart1 do

begin

Title.Text.Clear;

Title.Text.Add('График СЛУ');

s := TLineSeries.Create(nil);

s.Clear;

s.ParentChart := Chart1;

s.Title := 'Первое ЛУ';

t := TLineSeries.Create(nil);

t.Clear;

t.ParentChart := Chart1;

t.Title :='Второе ЛУ';

for i := a to b do

begin

s.AddXY(i, (strtofloat(edit5.text)-(strtofloat(edit1.text)*i))/strtofloat(edit4.text), '', clblue);

t.AddXY(i, (strtofloat(edit8.text)-(strtofloat(edit6.text)*i))/strtofloat(edit7.text), '', clred);

end;

end;

end;

function label1or12 ():string;

begin

if form1.label1.visible=true then result:=form1.label1.caption

else result:=form1.Label12.Caption;

end;

procedure TForm1.Button2Click(Sender: TObject);

var

j: integer;

list:string;

begin

list:=' ';

for j := 3 downto 1 do

begin

list:=list+' '+TCombobox(Form1.FindComponent('comboBox'+IntToStr(j))).Items[TCombobox(Form1.FindComponent('comboBox'+IntToStr(j))).ItemIndex];

end;

end;

procedure SwapEdit(a,b:integer);

var

x:string;

begin

x:=TEdit(Form1.FindComponent('edit'+IntToStr(a))).Text;

TEdit(Form1.FindComponent('edit'+IntToStr(a))).text:=TEdit(Form1.FindComponent('edit'+IntToStr(b))).Text;

TEdit(Form1.FindComponent('edit'+IntToStr(b))).Text:=x; end;

function MorP(a:extended):string;

begin

if a<0 then result:='-'

else result:='+';

end;

procedure XYtoYX;

var

a:integer;

begin

if form1.label2.caption='X' then

for a := 2 to 7 do

begin

TLabel(Form1.FindComponent('label'+IntToStr(a))).Caption:='Y';

form1.label14.caption:='Y';

form1.Label19.Caption:='Y';

u1:=true;

end else

begin

if form1.label2.caption='Y' then

for a := 2 to 7 do

begin

TLabel(Form1.FindComponent('label'+IntToStr(a))).Caption:='X';

form1.label14.caption:='X';

form1.Label19.Caption:='X';

u1:=false;

end;

end;

end;

procedure TForm1.Button3Click(Sender: TObject);

var

a:integer;

begin

XYtoYX;

if b=false then

begin

label13.Caption:='Математическая модель двойственной задачи';

b:=true;

label13.Left:=label13.Left-24;

end else

begin

label13.Caption:='Математическая модель прямой задачи';

b:=false;

label13.Left:=label13.Left+24;

end;

if label12.visible=false then

begin

label1.visible:=false;

label12.visible:=true;

end else

if label1.visible=false then

begin

label12.visible:=false;

label1.visible:=true;

end;

SwapEdit(2,5);

SwapEdit(3,8);

SwapEdit(4,6);

for a := 3 downto 1 do

begin

if TComboBox(Form1.FindComponent('combobox'+IntToStr(a))).ItemIndex=1 then

begin

TComboBox(Form1.FindComponent('combobox'+IntToStr(a))).ItemIndex:=0;

end else

begin

if TComboBox(Form1.FindComponent('combobox'+IntToStr(a))).ItemIndex=0 then

begin

TComboBox(Form1.FindComponent('combobox'+IntToStr(a))).ItemIndex:=1;

end;

end;

end;

end;

procedure TForm1.Button4Click(Sender: TObject);

var

s1,s2:string;

x1,x2:extended;

n,j:integer;

begin

memo1.Clear;

aa:=0;

x:=0;

pl;

memo1.Lines[aa-4]:=inttostr(1)+') Этап'; memo1.Lines[aa-3]:=p+combobox3.items[combobox3.Itemindex]+pp('<--')+label1or12+p+edit2.Text+'*'+label2.Caption+'1'+pp('+')+edit3.Text+'*'+label3.Caption+'2';

memo1.Lines[aa-1]:=pp('/')+edit1.Text+'*'+label4.caption+'1'+pp('+')+edit4.Text+'*'+label5.caption+'2'+pp(combobox2.items[combobox2.Itemindex])+edit5.text;

memo1.Lines[aa]:=pp('\')+edit6.Text+'*'+label6.caption+'1'+pp('+')+edit7.Text+'*'+label7.caption+'2'+pp(combobox2.items[combobox2.Itemindex])+edit8.text;

pl;

memo1.Lines[aa-1]:=pp('/')+edit1.Text+'*'+label4.caption+'1'+pp('+')+edit4.Text+'*'+label5.caption+'2'+pp('=')+edit5.text;

memo1.Lines[aa]:=pp('\')+edit6.Text+'*'+label6.caption+'1'+pp('+')+edit7.Text+'*'+label7.caption+'2'+pp('=')+edit8.text;

pl;

memo1.Lines[aa-1]:=pp('/')+edit1.Text+'*'+label4.caption+'1'+pp('+')+edit4.Text+'*'+label5.caption+'2'+pp('=')+edit5.text;

memo1.Lines[aa]:=pp('\')+edit6.Text+'*'+label6.caption+'1'+pp('=')+edit8.text+MorP(-1*(strtofloat(edit7.text)))+floattostr(abs(strtofloat(edit7.text)))+'*'+label7.caption+'2';

pl;

memo1.Lines[aa-1]:=pp('/')+edit1.Text+'*'+label4.caption+'1'+pp('+')+edit4.Text+ '*'+label5.caption+'2'+pp('=')+edit5.text;

s1:=floattostr(simpleroundto(strtofloat(edit8.Text)/strtofloat(edit6.Text),-2))+pp(MorP(-1*(strtofloat(edit7.text))))+floattostr(abs(simpleroundto(strtofloat(edit7.text)/strtofloat(edit6.Text),-2)))+'*'+label7.caption+'2';

memo1.Lines[aa]:=pp('\')+label6.caption+'1'+pp('=')+s1;

pl;

memo1.Lines[aa-1]:=pp('/')+edit1.Text+'*'+'('+s1+')'+pp('+')+edit4.Text+'*'+label5.caption+'2'+pp('=')+edit5.text;

memo1.Lines[aa]:=pp('\')+label6.caption+'1'+pp('=')+s1;

pl;

memo1.Lines[aa-1]:=pp('/')+floattostr(simpleroundto(strtofloat(edit1.Text)*(strtofloat(edit8.Text)/strtofloat(edit6.Text)),-2))+pp(MorP(-1*(strtofloat(edit7.text))))+floattostr(simpleroundto(strtofloat(edit1.Text)*abs(strtofloat(edit7.text)/strtofloat(edit6.Text)),-2))+'*'+label7.caption+'2'+pp('+')+edit4.Text+'*'+label5.caption+'2'+pp('=')+edit5.text;

memo1.Lines[aa]:=pp('\')+label6.caption+'1'+pp('=')+s1;

pl;

memo1.Lines[aa-1]:=pp('/')+floattostr(strtofloat(edit1.Text)*(-1*simpleroundto(strtofloat(edit7.text)/strtofloat(edit6.Text),-2))+strtofloat(edit4.Text))+'*'+label5.caption+'2'+pp('=')+floattostr(simpleroundto(strtofloat(edit5.text)-strtofloat(edit1.Text)*simpleroundto(strtofloat(edit8.Text)/strtofloat(edit6.Text),-2)));

memo1.Lines[aa]:=pp('\')+label6.caption+'1'+pp('=')+s1;

pl;

s2:=floattostr((strtofloat(edit5.text)-strtofloat(edit1.Text)*(strtofloat(edit8.Text)/strtofloat(edit6.Text)))/(strtofloat(edit1.Text)*(-1*(strtofloat(edit7.text)/strtofloat(edit6.Text)))+strtofloat(edit4.Text)));

memo1.Lines[aa-1]:=pp('/')+label5.caption+'2'+pp('=')+s2;

memo1.Lines[aa]:=pp('\')+label6.caption+'1'+pp('=')+s1;

pl;

memo1.Lines[aa-1]:=pp('/')+label5.caption+'2'+pp('=')+s2;

memo1.Lines[aa]:=pp('\')+label6.caption+'1'+pp('=')+floattostr((strtofloat(edit8.Text)/strtofloat(edit6.Text))+(-1*(strtofloat(edit7.text)/strtofloat(edit6.Text))*((strtofloat(edit5.text)-strtofloat(edit1.Text)*(strtofloat(edit8.Text)/strtofloat(edit6.Text)))/(strtofloat(edit1.Text)*(-1*(strtofloat(edit7.text)/strtofloat(edit6.Text)))+strtofloat(edit4.Text)))));

pl;

x1:=(strtofloat(edit8.Text)/strtofloat(edit6.Text))+(-1*(strtofloat(edit7.text)/strtofloat(edit6.Text))*((strtofloat(edit5.text)-strtofloat(edit1.Text)*(strtofloat(edit8.Text)/strtofloat(edit6.Text)))/(strtofloat(edit1.Text)*(-1*(strtofloat(edit7.text)/strtofloat(edit6.Text)))+strtofloat(edit4.Text))));

x2:=(strtofloat(edit5.text)-strtofloat(edit1.Text)*(strtofloat(edit8.Text)/strtofloat(edit6.Text)))/(strtofloat(edit1.Text)*(-1*(strtofloat(edit7.text)/strtofloat(edit6.Text)))+strtofloat(edit4.Text));

memo1.Lines[aa-1]:=pp(label1or12)+edit2.Text+'*'+label2.Caption+'1'+pp('+')+edit3.Text+'*'+label3.Caption+'2';

memo1.Lines[aa]:=pp(label1or12)+floattostr(strtofloat(edit2.Text)*x1)+pp('+')+floattostr(strtofloat(edit3.Text)*x2)+pp('=')+floattostr((strtofloat(edit2.Text)*x1)+(strtofloat(edit3.Text)*x2));

for n := 0 to x do

begin

memo1.Lines[6+n*4]:=inttostr(n+2)+') Этап';

end;

memo1.Lines.Add('');

if u1=true then

begin

edit13.text:=floattostr(simpleroundto(x1/x2,-2));

edit14.text:=floattostr(simpleroundto(x2/x1,-2));

label17.Visible:=true;

for j := 10 to 18 do

begin

TEdit(Form1.FindComponent('Edit'+IntToStr(j))).Visible:=true;

end;

end else

begin

edit13.text:='';

edit14.text:='';

label17.Visible:=false;

for j := 10 to 18 do

begin

TEdit(Form1.FindComponent('Edit'+IntToStr(j))).Visible:=false;

end;

end;

end;

procedure TForm1.ComboBox1CloseUp(Sender: TObject);

begin

combobox2.ItemIndex:=combobox1.ItemIndex;

end;

procedure TForm1.ComboBox2CloseUp(Sender: TObject);

begin

combobox1.ItemIndex:=combobox2.ItemIndex;

end;

procedure TForm1.Edit19Click(Sender: TObject);

begin

if v1=false then

begin

edit19.Text:='';

v1:=true;

end;

if edit20.text='' then edit20.Text:='1000'

end;

procedure TForm1.Edit20Click(Sender: TObject);

begin

if v2=false then

begin

edit20.Text:='';

v2:=true;

end;

if edit19.text='' then edit19.Text:='-1000'

end;

procedure TForm1.FormCreate(Sender: TObject);

begin

chart1.Title.Text.Clear;

end;

end.

83

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