fork download
  1. unit pi_;
  2.  
  3. interface
  4.  
  5. uses
  6. Windows, Messages, SysUtils, Classes, Graphics, Controls,
  7. Forms, Dialogs, StdCtrls;
  8.  
  9. type
  10. TForm1 = class(TForm)
  11. Edit1: TEdit; // точность вычисления
  12. Button1: TButton; // кнопка Вычислить
  13. Label1: TLabel;
  14. Label2: TLabel; // поле выода результата
  15. procedure Button1Click(Sender: TObject);
  16. private
  17. { Private declarations }
  18. public
  19. { Public declarations }
  20. end;
  21.  
  22. var
  23. Form1: TForm1;
  24.  
  25. implementation
  26.  
  27. {$R *.DFM}
  28.  
  29. procedure TForm1.Button1Click(Sender: TObject);
  30.  
  31. var
  32. pi:real; // вычисляемое значение ПИ
  33. t:real; // точность вычисления
  34. n:integer; // номер члена ряда
  35. elem:real; // значение члена ряда
  36. begin
  37. pi:=0;
  38. n:=1;
  39. t:=StrToFloat(edit1.text);
  40. elem:=1; // чтобы начать цикл
  41. while elem >= t do
  42. begin
  43. elem:=1/(2*n-1);
  44. if n MOD 2 = 0
  45. then pi:=pi-elem
  46. else pi:=pi+elem;
  47. n:=n+1;
  48. end;
  49. pi:=pi*4;
  50. label1.caption:= 'ПИ равно '+ FloatToStr(pi) + #13
  51. + 'Просуммировано '+IntTostr(n)+' членов ряда.';
  52. end;
  53.  
  54. end.
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.d(6): { } expected following aggregate declaration
prog.d(6): no identifier for declarator Windows
prog.d(10): expression expected, not 'class'
prog.d(11): semicolon expected, not 'Edit1'
prog.d(11): no identifier for declarator Edit1
prog.d(11): semicolon expected, not ':'
prog.d(11): Declaration expected, not ':'
prog.d(12): no identifier for declarator Button1
prog.d(12): semicolon expected, not ':'
prog.d(12): Declaration expected, not ':'
prog.d(13): no identifier for declarator Label1
prog.d(13): semicolon expected, not ':'
prog.d(13): Declaration expected, not ':'
prog.d(14): no identifier for declarator Label2
prog.d(14): semicolon expected, not ':'
prog.d(14): Declaration expected, not ':'
prog.d(15): found ':' when expecting ')'
prog.d(15): semicolon expected following function declaration
prog.d(15): no identifier for declarator TObject
prog.d(15): semicolon expected, not ')'
prog.d(15): Declaration expected, not ')'
stdout
Standard output is empty