Главная страница Случайная страница КАТЕГОРИИ: АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатикаИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханикаОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторикаСоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансыХимияЧерчениеЭкологияЭкономикаЭлектроника |
Unit Unit1;
Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Buttons, StdCtrls, Grids, Menus; Type 5. mtrx_t=array[0..50, 0..50]of string[10]; 6. TForm1 = class(TForm) 7. GroupBox1: TGroupBox; 8. Edit1: TEdit; 9. SpeedButton1: TSpeedButton; 10. OpenDialog1: TOpenDialog; 11. GroupBox2: TGroupBox; 12. StringGrid1: TStringGrid; 13. Button2: TButton; 14. MainMenu1: TMainMenu; 15. N1: TMenuItem; 16. N2: TMenuItem; 17. N3: TMenuItem; 18. N4: TMenuItem; 19. N5: TMenuItem; 20. N6: TMenuItem; 21. N7: TMenuItem; 22. GroupBox3: TGroupBox; 23. Edit3: TEdit; 24. Edit4: TEdit; 25. Label1: TLabel; 26. Label2: TLabel; 27. Edit2: TEdit; 28. procedure SpeedButton1Click(Sender: TObject); 29. procedure Button2Click(Sender: TObject); 30. procedure Button1Click(Sender: TObject); 31. procedure FormCreate(Sender: TObject); 32. procedure Button3Click(Sender: TObject); 33. procedure Button4Click(Sender: TObject); 34. procedure Button5Click(Sender: TObject); 35. procedure N7Click(Sender: TObject); 36. procedure N2Click(Sender: TObject); 37. procedure N3Click(Sender: TObject); 38. procedure N4Click(Sender: TObject); 39. procedure N9Click(Sender: TObject); 40. procedure N8Click(Sender: TObject); 41. procedure N6Click(Sender: TObject); Private 43. { Private declarations } Public 45. { Public declarations } End; Var 48. Form1: TForm1; 49. InFile, fh: String; 50. a, b: mtrx_t; 51. i, j, n, m, k: Integer; 52. myRect: TGridRect; 53. f: textfile; 54. ia, ja: array[1..20]of integer; Implementation Uses Unit2, Unit3, Unit4, Unit5; 57. {$R *.dfm} 58. procedure ReadFromFile(InFile: String; Var a: mtrx_t); Var 60. i, j, p: integer; 61. Inf: TextFile; 62. st: string; Begin AssignFile(InF, InFile); Reset(InF); Read(Inf, n, m); ReadLn(Inf); 68. for i: =0 to n-1 do Begin Readln(Inf, st); 71. for j: =0 to m do Begin 73. p: =pos(' ', st)-1; 74. if p< =0 then p: =length(st); 75. a[i, j]: =copy(st, 1, p); 76. delete(st, 1, p+1); End; End; 79. for j: =m-1 downto 1 do 80. a[0, j]: =a[0, j-1]; 81. a[0, 0]: =''; 82. for i: =1 to n do 83. for j: =1 to m do 84. if pos('.', a[i, j])< > 0 Then Begin 86. insert(', ', a[i, j], pos('.', a[i, j])); 87. delete(a[i, j], pos('.', a[i, j]), 1); End; CloseFile(Inf); End; 91. procedure writetogrid(b: mtrx_t); Var 93. i, j: integer; Begin 95. Form1.StringGrid1.RowCount: =n; 96. Form1.StringGrid1.ColCount: =m; 97. for i: =0 to n do 98. for j: =0 to m do 99. Form1.stringgrid1.cells[j, i]: =b[i, j]; End; 101. procedure writetofile(b: mtrx_t; i, j: integer); Var 103. i1, j1: integer; Begin 105. if (i< > 0)and(j< > 0) then writeln(f, '[', i, ', ', j, ']=', b[i, j]); 106. for i1: =0 to n do Begin 108. for j1: =0 to m do 109. write(f, b[i1, j1]: 5); Writeln(f); End; 112. writeln(f, '------------------------------------------------------------------'); End; 114. procedure TForm1.SpeedButton1Click(Sender: TObject); Begin 116. OpenDialog1.FileName: =''; 117. OpenDialog1.InitialDir: =ExtractFilePath(Application.ExeName);; OpenDialog1.Execute; 119. Edit1.Text: =OpenDialog1.FileName; 120. InFile: =OpenDialog1.FileName; 121. Button2.Enabled: =True; End; 123. function nozero(b: mtrx_t): boolean; Var 125. i, j: integer; 126. l: boolean; Begin 128. l: =true; 129. for i: =1 to n-1 do 130. if b[i, 0]='0' then 131. for j: =1 to m-2 do 132. if strtofloat(b[i, j])< > 0 then Begin 134. l: =false; Break; End; 137. result: =l; End; 139. function notirek(b: mtrx_t): boolean; Var 141. i: integer; Begin 143. for i: =1 to n-2 do 144. if strtofloat(b[i, m-1])< 0 then Begin 146. result: =false; Exit; End; 149. result: =true; End; 151. function nooptimal(b: mtrx_t): boolean; Var 153. j: integer; Begin 155. for j: =1 to m-2 do 156. if strtofloat(b[n-1, j])< 0 then Begin 158. result: =false; Exit; End; 161. result: =true; End; 163. procedure FindEl0(b: mtrx_t; var i1, j1: integer); 164. type dt=record 165. i: integer; 166. v: real; End; Var 169. i, j, t, i2: integer; 170. min: real; 171. d: array[1..30]of dt; Begin 173. i: =0; j: =0; t: =0; Repeat
|