Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Grids,
- Vcl.Menus;
- type
- TForm1 = class(TForm)
- StringGrid1: TStringGrid;
- MainMenu1: TMainMenu;
- N1: TMenuItem;
- N2: TMenuItem;
- N3: TMenuItem;
- N4: TMenuItem;
- N5: TMenuItem;
- N6: TMenuItem;
- N7: TMenuItem;
- N8: TMenuItem;
- N9: TMenuItem;
- N10: TMenuItem;
- N11: TMenuItem;
- N12: TMenuItem;
- N13: TMenuItem;
- N14: TMenuItem;
- N15: TMenuItem;
- StringGrid2: TStringGrid;
- OpenDialog1: TOpenDialog;
- SaveDialog1: TSaveDialog;
- procedure N3Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- konus = record
- x:single;
- y:single;
- r:single;
- h:single;
- end;
- type massive = array of konus;
- var
- Form1: TForm1;
- konuses: massive;
- f: string;
- tfile: file;
- implementation
- {$R *.dfm}
- procedure sort(var v:massive; l,r:longint);
- var
- i,j:integer;
- w,q:konus;
- begin
- i := l; j := r;
- q := v[(l+r) div 2];
- repeat
- while (v[i].h * 1.047 * v[i].r * v[i].r < q.h * 1.047 * q.r * q.r) do inc(i);
- while (q.h * 1.047 * q.r * q.r < v[i].h * 1.047 * v[i].r * v[i].r) do dec(j);
- if i <= j then begin
- w := v[i]; v[i] := v[j]; v[j] := w;
- inc(i); dec(j)
- end;
- until (i > j);
- if (l < j) then sort(v,l,j);
- if (i < r) then sort(v,i,r);
- end;
- procedure find(var v,x:massive);
- var
- sqrs: array of single;
- middle, sum, count: single;
- i,k: integer;
- begin
- k := 0;
- for i := 0 to length(v)-1 do begin
- sum := sum + v[i].h * 1.047 * v[i].r * v[i].r;
- count := count + 1;
- end;
- middle := sum / count;
- for i := 0 to length(v)-1 do begin
- if (v[i].h * 1.047 * v[i].r * v[i].r < middle) then begin
- k := k+1;
- SetLength(x,k);
- x[k] := v[i];
- end;
- end;
- end;
- procedure add(var v:massive; x,y,r,h:single);
- var
- l: integer;
- begin
- l := length(v);
- l := l + 1;
- SetLength(v,l);
- v[l].x := x; v[l].y := y; v[l].r := r; v[l].h := h;
- end;
- procedure TForm1.N3Click(Sender: TObject);
- var i,n:integer;
- a: konus;
- begin
- if OpenDialog1.Execute = true then
- begin
- f := OpenDialog1.FileName;
- Form1.Caption := f;
- assignfile(tfile,f);
- reset(tfile);
- n := FileSize(f);
- StringGrid1.RowCount := n+1;
- for i := 1 to n do
- begin
- read(f,a);
- StringGrid1.Cells[1,i] := IntToStr(a.x);
- StringGrid1.Cells[2,i] := IntToStr(a.y);
- StringGrid1.Cells[3,i] := IntToStr(a.r);
- StringGrid1.Cells[4,i] := IntToStr(a.h);
- end;
- closefile(tfile);
- for i := 0 to n do StringGrid1.Cells[0,i] := IntToStr(i);
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement