13.04.2010, 23:50
|
Прохожий
|
|
Регистрация: 09.04.2010
Сообщения: 9
Репутация: 10
|
|
Всем спасибо!
Заработало!
Надо было просто определить точный размер, снова открыть файл и уже тогда считать!
Вот так работает)
PHP код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var f:textfile;
a:array [1..100000] of double;
i, STr_s:integer;
min:double;
s:string;
begin
If OpenDialog1.Execute //открыть диалог для поиска файла
then begin
assignfile(f,OpenDialog1.FileName);
reset(f);
Str_s:=0;
While Not Eof(F) do //пока не конец файла
Begin
ReadLn(F, S); //считать строку
Inc(Str_S); //увеличить Str_S на 1
End;
closefile(f);
assignfile(f,OpenDialog1.FileName);
reset(f);
readln(f,min);
a[1]:=min;
for i:=2 to STr_s do
begin
readln(f,a[i]);
if a[i]<min then begin min:=a[i];
end;
end;
label1.Caption:='наименьшее число = '+floattostr(min);
closefile(f);
end
else SHowMessage('Файл не выбран!');
exit;
end;
end.
|