Добрый вечер. Очень нужна помощь с программой. Вопрос такой: как мои ответы по x1,х2,х3 из дробных чисел в обычные. т.е как написать код, чтобы - вопрос №2450389

произошло деление?(Простите, что пишу глупые вопросы. Но сама не разберусь и помочь некому)(Решение систем уравнений методом крамера).Заранее благодарю.
Код такой:
  1. unit Unit1;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, Grids, StdCtrls, ExtCtrls, ComCtrls;
  6. type
  7. TForm1 = class(TForm)
  8. Panel1: TPanel;
  9. StringGrid1: TStringGrid;
  10. Button1: TButton;
  11. Label7: TLabel;
  12. Panel2: TPanel;
  13. Label1: TLabel;
  14. StringGrid2: TStringGrid;
  15. StringGrid3: TStringGrid;
  16. Label2: TLabel;
  17. StringGrid4: TStringGrid;
  18. Label3: TLabel;
  19. Label4: TLabel;
  20. Label5: TLabel;
  21. Label6: TLabel;
  22. StatusBar1: TStatusBar;
  23. procedure FormCreate(Sender: TObject);
  24. procedure Button1Click(Sender: TObject);
  25. private
  26. { Private declarations }
  27. public
  28. { Public declarations }
  29. end;
  30. type
  31. TMArray =array [0..3] of real;
  32. var
  33. Form1: TForm1;
  34. implementation
  35. {$R *.dfm}
  36. procedure TForm1.FormCreate(Sender: TObject);
  37. begin
  38. StringGrid1.Cells[0,0]:='';
  39. StringGrid1.Cells[1,0]:='';
  40. StringGrid1.Cells[2,0]:='';
  41. StringGrid1.Cells[3,0]:='';
  42. StringGrid1.Cells[0,1]:='';
  43. StringGrid1.Cells[1,1]:='';
  44. StringGrid1.Cells[2,1]:='';
  45. StringGrid1.Cells[3,1]:='';
  46. StringGrid1.Cells[0,2]:='';
  47. StringGrid1.Cells[1,2]:='';
  48. StringGrid1.Cells[2,2]:='';
  49. StringGrid1.Cells[3,2]:='';
  50. end;
  51. function podstanov (mas1,mas2,mas3:TMArray):real;
  52. begin
  53. Result:= mas1[0]*mas2[1]*mas3[2]+mas2[0]*mas3[1]*mas1[2]+mas1[1]*mas2[2]*mas3[0]-
  54. mas3[0]*mas2[1]*mas1[2]-mas2[0]*mas1[1]*mas3[2]-mas3[1]*mas2[2]*mas1[0];
  55. end;
  56. procedure TForm1.Button1Click(Sender: TObject);
  57. var mas1,mas2,mas3:TMArray;
  58. i,j:integer; x1,x2,x3:real;
  59. Delta,Delta1,Delta2,Delta3:real;
  60. begin
  61. for i:=0 to StringGrid1.ColCount-1 do
  62. begin
  63. mas1[i]:=StrToFloat(StringGrid1.cells[i,0]);
  64. mas2[i]:=StrToFloat(StringGrid1.Cells[i,1]);
  65. mas3[i]:=StrToFloat(StringGrid1.Cells[i,2]);
  66. end;
  67. Delta:=podstanov(mas1,mas2,mas3); //дельта
  68. for j:=0 to StringGrid1.RowCount do
  69. begin
  70. StringGrid2.Cells[0,j]:=StringGrid1.Cells[3,j];
  71. StringGrid2.Cells[1,j]:=StringGrid1.Cells[1,j];
  72. StringGrid2.Cells[2,j]:=StringGrid1.Cells[2,j];
  73. StringGrid2.Cells[3,j]:='0';
  74. end;
  75. for i:=0 to StringGrid2.ColCount-1 do
  76. begin
  77. mas1[i]:=StrToFloat(StringGrid2.cells[i,0]);
  78. mas2[i]:=StrToFloat(StringGrid2.Cells[i,1]);
  79. mas3[i]:=StrToFloat(StringGrid2.Cells[i,2]);
  80. end;
  81. Delta1:=podstanov(mas1,mas2,mas3); //дельта
  82. for j:=0 to StringGrid3.RowCount do
  83. begin
  84. StringGrid3.Cells[0,j]:=StringGrid1.Cells[0,j];
  85. StringGrid3.Cells[1,j]:=StringGrid1.Cells[3,j];
  86. StringGrid3.Cells[2,j]:=StringGrid1.Cells[2,j];
  87. StringGrid3.Cells[3,j]:='0';
  88. end;
  89. for i:=0 to StringGrid3.ColCount-1 do
  90. begin
  91. mas1[i]:=StrToFloat(StringGrid3.cells[i,0]);
  92. mas2[i]:=StrToFloat(StringGrid3.Cells[i,1]);
  93. mas3[i]:=StrToFloat(StringGrid3.Cells[i,2]);
  94. end;
  95. Delta2:=podstanov(mas1,mas2,mas3);
  96. for j:=0 to StringGrid4.RowCount do
  97. begin
  98. StringGrid4.Cells[0,j]:=StringGrid1.Cells[0,j];
  99. StringGrid4.Cells[1,j]:=StringGrid1.Cells[1,j];
  100. StringGrid4.Cells[2,j]:=StringGrid1.Cells[3,j];
  101. StringGrid4.Cells[3,j]:='0';
  102. end;
  103. for i:=0 to StringGrid3.ColCount-1 do
  104. begin
  105. mas1[i]:=StrToFloat(StringGrid4.cells[i,0]);
  106. mas2[i]:=StrToFloat(StringGrid4.Cells[i,1]);
  107. mas3[i]:=StrToFloat(StringGrid4.Cells[i,2]);
  108. end;
  109. Delta3:=podstanov(mas1,mas2,mas3);
  110. Label1.Caption:=FloatToStr(Delta1)+#13+'--------------'+#13+FloatToStr(Delta);
  111. Label2.Caption:=FloatToStr(Delta2)+#13+'--------------'+#13+FloatToStr(Delta);
  112. Label3.Caption:=FloatToStr(Delta3)+#13+'--------------'+#13+FloatToStr(Delta);
  113. end;
  114. end.
11.05.17
0 ответов
Ответов пока нет
Посмотреть всех экспертов из раздела Технологии > Delphi
Пользуйтесь нашим приложением Доступно на Google Play Загрузите в App Store