![]() Главная страница Случайная страница КАТЕГОРИИ: АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатикаИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханикаОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторикаСоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансыХимияЧерчениеЭкологияЭкономикаЭлектроника |
Inc(i);
176. if b[i, 0]='0' then Begin 178. j: =0; Repeat Inc(j); 181. until (Strtofloat(b[i, j])> 0)or(j> =m-1); End; 183. until (b[i, 0]='0')and(j< m-1); 184. for i: =1 to n-2 do 185. if (strtofloat(b[i, j])< > 0)and(strtofloat(b[i, m-1])> 0)and (strtofloat(b[i, j])> 0)and(b[i, 0]='0') then Begin Inc(t); 188. d[t].v: =strtofloat(b[i, m-1]) / strtofloat(b[i, j]); 189. d[t].i: =i; End; 191. min: =d[1].v; i1: =d[1].i; 192. if t> =2 then 193. for i2: =2 to t do 194. if min> d[i2].v then Begin 196. i1: =d[i2].i; 197. min: =d[i2].v; End; 199. j1: =j; End; 201. procedure FindEl1(b: mtrx_t; var i1, j1: integer); 202. type dt=record 203. i: integer; 204. v: real; End; Var 207. i, j, t, i2: integer; 208. min: real; 209. d: array[1..30]of dt; Begin 211. i: =0; j: =0; t: =0; Repeat Inc(i); 214. until strtofloat(b[i, m-1])< 0; Repeat Inc(j); 217. until Strtofloat(b[i, j])< 0; 218. for i: =1 to n-2 do 219. if (strtofloat(b[i, m-1])< 0) and (strtofloat(b[i, j])< 0) then Begin Inc(t); 222. d[t].v: =strtofloat(b[i, m-1]) / strtofloat(b[i, j]); 223. d[t].i: =i; End; 225. min: =d[1].v; i1: =d[1].i; 226. if t> =2 then 227. for i2: =2 to t do 228. if min> d[i2].v then Begin 230. i1: =d[i2].i; 231. min: =d[i2].v; End; 233. j1: =j; End; 235. procedure FindEl2(b: mtrx_t; var i1, j1: integer); 236. type dt=record 237. i: integer; 238. v: real; End; Var 241. i, j, t, i2: integer; 242. min: real; 243. d: array[1..30]of dt; Begin 245. i: =0; j: =0; t: =0; 246. for j: =1 to m-2 do 247. if strtofloat(b[n-1, j])< 0 then Begin Inc(t); 250. d[t].v: =strtofloat(b[n-1, j]); 251. d[t].i: =j; End; 253. min: =d[1].v; j: =d[1].i; 254. if t> =2 then 255. for i: =1 to t do 256. if min> d[i].v then Begin 258. min: =d[i].v; 259. j: =d[i].i; End; 261. t: =0; 262. for i: =1 to n-2 do 263. if (strtofloat(b[i, j])> 0) then Begin Inc(t); 266. d[t].v: =strtofloat(b[i, m-1]) / strtofloat(b[i, j]); 267. d[t].i: =i; End; 269. min: =d[1].v; i1: =d[1].i; 270. if t> =2 then 271. for i2: =2 to t do 272. if min< d[i2].v then Begin 274. min: =d[i2].v; 275. i1: =d[i2].i; End; 277. j1: =j; End; 279. procedure jordan(var b: mtrx_t; i1, j1, c: integer); Var 281. el: string[10]; 282. i, j: integer; Begin 284. el: =b[i1, j1]; 285. b[0, 0]: =b[i1, 0]; 286. b[i1, 0]: =copy(b[0, j1], 2, length(b[0, j1])); 287. b[0, j1]: ='-'+b[0, 0]; 288. b[0, 0]: =''; 289. b[i1, j1]: ='1'; 290. for i: =1 to n-1 do 291. for j: =1 to m-1 do 292. if Not((i=i1)or(j=j1)) then 293. b[i, j]: =floattostr((strtofloat(el)*strtofloat(b[i, j]))-(strtofloat(b[i, j1])*strtofloat(b[i1, j]))); 294. if c=1 then 295. for i: =1 to n-1 do 296. b[i, j1]: =FloatToStr(Strtofloat(b[i, j1])*(-1)); 297. for i: =1 to n-1 do 298. for j: =1 to m-1 do 299. b[i, j]: =floattostr(strtofloat(b[i, j]) / strtofloat(el)); End; 301. procedure delcol(var b: mtrx_t; j1: integer); Var 303. i, j: integer; Begin 305. for j: =j1 to m-1 do 306. for i: =0 to n do Begin 308. b[i, j]: =b[i, j+1]; 309. b[i, j+1]: =''; End; Dec(m); End; 313. procedure TForm1.Button2Click(Sender: TObject); Begin 315. StringGrid1.Visible: =true; 316. GroupBox2.Visible: =true; ReadFromFile(InFile, a); 318. b: =a; 319. fh: =copy(opendialog1.FileName, 1, length(opendialog1.FileName)-3)+'.out'; Assignfile(f, fh); Rewrite(f); WriteToGrid(b); End; 324. procedure TForm1.Button1Click(Sender: TObject); Begin If Not(NoZero(b)) Then Begin Inc(k); 329. Edit2.Text: =Inttostr(k); FindEl0(b, i, j); 331. i: =ia[k]; 332. j: =ja[k]; Writetofile(b, i, j); Jordan(b, i, j, 0); DelCol(b, j); WriteToGrid(b); End Else If Not(NoTirek(b)) Then Begin Inc(k); 341. Edit2.Text: =Inttostr(k); FindEl1(b, i, j); 343. i: =ia[k]; 344. j: =ja[k]; Writetofile(b, i, j); Jordan(b, i, j, 1); WriteToGrid(b); End Else If Not(NoOptimal(b)) Then Begin Inc(k); 352. Edit2.Text: =Inttostr(k); FindEl2(b, i, j); 354. i: =ia[k]; 355. j: =ja[k]; Writetofile(b, i, j); Jordan(b, i, j, 1); WriteToGrid(b); End Else Begin 361. MessageDlg('Оптималды шешiм табылды! ', mtInformation, [mbOk], 0); Writetofile(b, 0, 0); Closefile(f); 364. Form2.Visible: =true; End; End; 367. procedure TForm1.FormCreate(Sender: TObject); Begin 369. k: =0; 370. edit2.Text: =inttostr(k); End; 372. procedure TForm1.Button3Click(Sender: TObject); Begin Close; End; 376. procedure TForm1.Button4Click(Sender: TObject); Begin
|