Технологии
Добрый вечер. Очень нужна помощь с программой. Вопрос такой: как мои ответы по x1,х2,х3 из дробных чисел в обычные. т.е как написать код, чтобы - вопрос №2450389
произошло деление?(Простите, что пишу глупые вопросы. Но сама не разберусь и помочь некому)(Решение систем уравнений методом крамера).Заранее благодарю.
Код такой:
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, Grids, StdCtrls, ExtCtrls, ComCtrls;
- type
- TForm1 = class(TForm)
- Panel1: TPanel;
- StringGrid1: TStringGrid;
- Button1: TButton;
- Label7: TLabel;
- Panel2: TPanel;
- Label1: TLabel;
- StringGrid2: TStringGrid;
- StringGrid3: TStringGrid;
- Label2: TLabel;
- StringGrid4: TStringGrid;
- Label3: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- Label6: TLabel;
- StatusBar1: TStatusBar;
- procedure FormCreate(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- type
- TMArray =array [0..3] of real;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- StringGrid1.Cells[0,0]:='';
- StringGrid1.Cells[1,0]:='';
- StringGrid1.Cells[2,0]:='';
- StringGrid1.Cells[3,0]:='';
- StringGrid1.Cells[0,1]:='';
- StringGrid1.Cells[1,1]:='';
- StringGrid1.Cells[2,1]:='';
- StringGrid1.Cells[3,1]:='';
- StringGrid1.Cells[0,2]:='';
- StringGrid1.Cells[1,2]:='';
- StringGrid1.Cells[2,2]:='';
- StringGrid1.Cells[3,2]:='';
- end;
- function podstanov (mas1,mas2,mas3:TMArray):real;
- begin
- Result:= mas1[0]*mas2[1]*mas3[2]+mas2[0]*mas3[1]*mas1[2]+mas1[1]*mas2[2]*mas3[0]-
- mas3[0]*mas2[1]*mas1[2]-mas2[0]*mas1[1]*mas3[2]-mas3[1]*mas2[2]*mas1[0];
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- var mas1,mas2,mas3:TMArray;
- i,j:integer; x1,x2,x3:real;
- Delta,Delta1,Delta2,Delta3:real;
- begin
- for i:=0 to StringGrid1.
ColCount-1 do - begin
- mas1[i]:=StrToFloat(StringGrid1.cells[i,0]);
- mas2[i]:=StrToFloat(StringGrid1.Cells[i,1]);
- mas3[i]:=StrToFloat(StringGrid1.Cells[i,2]);
- end;
- Delta:=podstanov(mas1,mas2,mas3); //дельта
- for j:=0 to StringGrid1.RowCount do
- begin
- StringGrid2.Cells[0,j]:=StringGrid1.Cells[3,j];
- StringGrid2.Cells[1,j]:=StringGrid1.Cells[1,j];
- StringGrid2.Cells[2,j]:=StringGrid1.Cells[2,j];
- StringGrid2.Cells[3,j]:='0';
- end;
- for i:=0 to StringGrid2.ColCount-1 do
- begin
- mas1[i]:=StrToFloat(StringGrid2.cells[i,0]);
- mas2[i]:=StrToFloat(StringGrid2.Cells[i,1]);
- mas3[i]:=StrToFloat(StringGrid2.Cells[i,2]);
- end;
- Delta1:=podstanov(mas1,mas2,mas3); //дельта
- for j:=0 to StringGrid3.RowCount do
- begin
- StringGrid3.Cells[0,j]:=StringGrid1.Cells[0,j];
- StringGrid3.Cells[1,j]:=StringGrid1.Cells[3,j];
- StringGrid3.Cells[2,j]:=StringGrid1.Cells[2,j];
- StringGrid3.Cells[3,j]:='0';
- end;
- for i:=0 to StringGrid3.ColCount-1 do
- begin
- mas1[i]:=StrToFloat(StringGrid3.cells[i,0]);
- mas2[i]:=StrToFloat(StringGrid3.Cells[i,1]);
- mas3[i]:=StrToFloat(StringGrid3.Cells[i,2]);
- end;
- Delta2:=podstanov(mas1,mas2,mas3);
- for j:=0 to StringGrid4.RowCount do
- begin
- StringGrid4.Cells[0,j]:=StringGrid1.Cells[0,j];
- StringGrid4.Cells[1,j]:=StringGrid1.Cells[1,j];
- StringGrid4.Cells[2,j]:=StringGrid1.Cells[3,j];
- StringGrid4.Cells[3,j]:='0';
- end;
- for i:=0 to StringGrid3.ColCount-1 do
- begin
- mas1[i]:=StrToFloat(StringGrid4.cells[i,0]);
- mas2[i]:=StrToFloat(StringGrid4.Cells[i,1]);
- mas3[i]:=StrToFloat(StringGrid4.Cells[i,2]);
- end;
- Delta3:=podstanov(mas1,mas2,mas3);
- Label1.Caption:=FloatToStr(Delta1)+#13+'--------------'+#13+FloatToStr(Delta);
- Label2.Caption:=FloatToStr(Delta2)+#13+'--------------'+#13+FloatToStr(Delta);
- Label3.Caption:=FloatToStr(Delta3)+#13+'--------------'+#13+FloatToStr(Delta);
- end;
- end.
май 11, 2017 г.
-
Всего ответов: 0
Похожие вопросы
Решено
помогите написать простую программу теста на делфи, которая работает с текстовым файлом..Мне очень трудно понять как из текстового документа по строкам считывается информация и выводится в компонент
март 26, 2014 г.
Технологии
var a,b,s,n,u:integer; begin readln (s); что это? n:= s mod 4; u:= s mod 2; if (S mod 2>0) then writeln ('Инвалиды') else for a:=0 to n do begin for b:=0 to u do begin if ((a*4) + (b*2) = s) then writeln (a,b); end;
февраль 8, 2016 г.
Технологии