27.04.2015, 00:01 | #1 (permalink) |
Новичок
Регистрация: 26.04.2015
Сообщений: 1
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 10
|
Блок-схема
Код программы: unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, Unit1, Printers, Unit3, StdCtrls, jpeg, ExtCtrls, Menus, ShellAPI, ComCtrls, Spin, XPMan, Math; type Masiv = array[0..10, 0..10] of real; TForm2 = class(TForm) StringGrid1: TStringGrid; Label1: TLabel; Label2: TLabel; Edit1: TEdit; Edit2: TEdit; Image1: TImage; Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; Button5: TButton; Button6: TButton; Button7: TButton; Button8: TButton; Button9: TButton; Button10: TButton; OpenDialog1: TOpenDialog; SaveDialog1: TSaveDialog; Button11: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button7Click(Sender: TObject); procedure Button8Click(Sender: TObject); procedure Button9Click(Sender: TObject); procedure Button10Click(Sender: TObject); function det(A: Masiv; n: integer): real; procedure Button11Click(Sender: TObject); procedure Button6Click(Sender: TObject); procedure Button3Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var a: Masiv; Form2: TForm2; i,j,m,n,k,z:integer; r:real; det:real; prn:textfile; f:textFile; s,s1:string; implementation {$R *.dfm} procedure TForm2.Button1Click(Sender: TObject); begin z:=StrToInt(Edit1.Text); StringGrid1.ColCount:=z; StringGrid1.RowCount:=z; end; procedure TForm2.Button4Click(Sender: TObject); begin Randomize; for i:=0 to z do for j:=0 to z do StringGrid1.Cells[i,j]:=IntToStr(Random(15)); end; procedure TForm2.Button5Click(Sender: TObject); begin assignprn(prn); rewrite(prn); printer.canvas.font := stringgrid1.font; for k := 0 to stringgrid1.ControlCount-1 do writeln(prn, stringgrid1.ControlCount); closefile(prn); end; procedure TForm2.Button7Click(Sender: TObject); begin form2.Hide; form1.Show; end; procedure TForm2.Button8Click(Sender: TObject); begin form2.Hide; form3.Show; end; procedure TForm2.Button9Click(Sender: TObject); begin close; end; procedure TForm2.Button10Click(Sender: TObject); begin for i := 0 to z do begin for j := 0 to z do StringGrid1.Cells[i, j] := ''; Edit1.Text:= ''; Edit2.Text:= ''; end; end; procedure TForm2.Button2Click(Sender: TObject); var i, j, k: integer; r, res, d: real; begin for i := 1 to z do begin for j := 1 to z do a[i,j] := StrToFloat(StringGrid1.Cells[j-1, i-1]); end; d := det(a, z); Edit2.Text:= FloatToStr(d); end; function TForm2.det(a: Masiv; n: integer): real; var s, d, dd: real; a1: Masiv; ii, jj, j, m: integer; begin if (n = 2) then s := a[1, 1] * a[2, 2] - a[1, 2] * a[2, 1] else begin s := 0; for j := 1 to n do begin d := power(-1, 1 + j) * a[1, j]; m := n - 1; ii := 2; while (ii <= n) do begin jj := 1; while (jj <= n) do begin if (jj < j) then a1[ii - 1, jj] := a[ii, jj]; if (jj > j) then a1[ii - 1, jj - 1] := a[ii, jj]; if (jj = j) then begin a1[ii - 1, jj] := a[ii, jj + 1]; jj := jj + 1; end; jj := jj + 1; end; ii := ii + 1; end; d := d * det(a1, m); s := s + d; end; end; det := s; end; procedure TForm2.Button11Click(Sender: TObject); var myhelp: string; begin myhelp:=extractfilepath(application.ExeName) + 'NewProject.chm'; shellexecute(handle, 'open', pchar(myhelp), nil, nil, sw_restore); end; procedure TForm2.Button6Click(Sender: TObject); Var f: TextFile; i, k: Integer; s,s1:string; begin if SaveDialog1.Execute then begin AssignFile(f,SaveDialog1.FileName); Rewrite(f); Append(f); for i:=0 to StringGrid1.RowCount-1 do begin for k:=0 to StringGrid1.ColCount-1 do begin s1:= s1 + ' '+ StringGrid1.Cells[k,i]; end; Writeln(f,s1); s1:=''; end; CloseFile(f); end; end; procedure TForm2.Button3Click(Sender: TObject); begin if OpenDialog1.Execute then assignfile(f,OpenDialog1.FileName); reset(f); for i:=0 to StringGrid1.RowCount-1 do for j:=0 to StringGrid1.ColCount-1 do begin read(f,a[i,j]); StringGrid1.Cells[j,i]:=floattostr(a[i,j]); end; closeFile(f); end; end. |
27.04.2015, 00:01 | |
Helpmaster
Member
Регистрация: 08.03.2016
Сообщений: 0
|
Я думаю, что тут найдется много полезного для вас Блок-схема Блок-схема Блок-схема Блок-схема Блок-схема 1 Блок-схема 2 |
Ads | |
Member
Регистрация: 31.10.2006
Сообщений: 40200
Записей в дневнике: 0
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 55070
|
|
|