dizballanze

Untitled

Nov 14th, 2011
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.98 KB | None | 0 0
  1. unit Unit4;
  2.  
  3. interface
  4.  
  5. uses
  6.   Classes, StdCtrls, SysUtils;
  7.  
  8. type
  9.   Calculator = class(TThread)
  10.   private
  11.     { Private declarations }
  12.   protected
  13.     procedure Execute; override;
  14.   public
  15.     listbox_input: TListBox;
  16.     listbox_output: TListBox;
  17.     result: TLabel;
  18.     start: TDateTime;
  19.     finish: TDateTime;
  20.   end;
  21.  
  22. implementation
  23.  
  24. { Calculator }
  25.  
  26. procedure Calculator.Execute;
  27. var
  28.   count: integer;
  29.   prev: double;
  30.   TimeStamp : TTimeStamp;
  31. begin
  32.   count := 1;
  33.   prev := 0;
  34.   while count < 100 do
  35.   begin
  36.     if listbox_input.Items.Count >= count then
  37.     begin
  38.       prev := (0.1 * StrToInt(listbox_input.Items[count - 1]) + prev) / 2;
  39.       listbox_output.Items.add(FloatToStr(prev));
  40.       count := count + 1;
  41.     end;
  42.   end;
  43.   finish := Time;
  44.   TimeStamp := DateTimeToTimeStamp(finish - start);
  45.   Dec(TimeStamp.Date, TTimeStamp(DateTimeToTimeStamp(0)).Date);
  46.   result.Caption := FloatToStr((TimeStamp.Date*24*60*60)+(TimeStamp.Time));
  47. end;
  48.  
  49. end.
  50.  
  51.  
Advertisement
Add Comment
Please, Sign In to add comment