⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 计算出π的值 用0~9这10个数字组成一些五位数字
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    GroupBox1: TGroupBox;
    Memo1: TMemo;
    RadioGroup1: TRadioGroup;
    Label1: TLabel;
    Memo2: TMemo;
    Edit1: TEdit;
    Button2: TButton;
    Button_makea5num: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button_makea5numClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  astringlist:tstringlist;
  const big=3.1416;
  small=3.1415;
      //3.1415926535


implementation

{$R *.dfm}
function makenum5():real;
var
i,j:integer;
num_c:double;
//astringlist:tstringlist;
//num_a,num_b:integer;
//num_c:double;
//num_d:single;
begin
for i:= 99999 downto 10000  do
begin

         for j:= 10000 to 99999  do
         begin
         num_c:=i/j;
    if (num_c>small) and (num_c<big) then   //
      begin
      aStringList.Add(Format('%10.8f',[num_c]));    //添加到字符组里面
      showmessage(Format('%10.8f',[num_c]));
       //  makenum5:=num_c;//
         //break;
         end;
        end;
      //  break;
end;

end;

procedure TForm1.Button1Click(Sender: TObject);
var
     int1,int2,int3:real;
  str1:String;
begin
//showmessage(FloatToStrF(3333.33333,ffFixed,8,5));   // 倒数第二个是管原来数字的有效位 最后的参数管小数精度
showmessage(FloatToStrF(makenum5,ffFixed,8,8));   //  最后的参数管小数精度
//String1:=Format('%10.2f',[Float1]);
//showmessage(Format('%10.2f',[makenum5]));
end;



procedure TForm1.FormCreate(Sender: TObject);
begin
aStringList:=TStringList.Create;  //初始化
end;

procedure TForm1.Button2Click(Sender: TObject);
var
i:integer;
begin
   for i:=0 to aStringList.Count-1 do
   begin
      showmessage(aStringList[i]);
   end;
end;
 //制造一个五位数
procedure TForm1.Button_makea5numClick(Sender: TObject);
begin
//
end;

end.
        //格式转换
{
 var  
    Float1:Double;  
   
  Float1:=(int1*22.34)/60+int2+(int3/34);
  String1:=Format('%10.2f',[Float1]);     //这是右对齐,前面不足部分补空格
   
  String1:=Format('%-10.2f',[Float1]);   //这是左对齐,后面不足部分补空格  
    格式基本同C语言。  
  可以用Trim(String1)去掉前后空格。
    无限不循环小数:3.1415926^^^
回答者:AZ5691800 - 助理 二级 4-8 14:48
3.1415926535 8979323846 2643383279 5028841971 6939937510

5820974944 5923078164 0628620899 8628034825 3421170679

8214808651 3282306647 0938446095 5058223172 5359408128

4811174502 8410270193 8521105559 6446229489 5493038196

4428810975 6659334461 2847564823 3786783165 2712019091

4564856692 3460348610 4543266482 1339360726 0249141273

7245870066 0631558817 4881520920 9628292540 9171536436

7892590360 0113305305 4882046652 1384146951 9415116094

3305727036 5759591953 0921861173 8193261179 3105118548

0744623799 6274956735 1885752724 8912279381 8301194912

9833673362 4406566430 8602139494 6395224737 1907021798

6094370277 0539217176 2931767523 8467481846 7669405132

0005681271 4526356082 7785771342 7577896091 7363717872

1468440901 2249534301 4654958537 1050792279 6892589235

4201995611 2129021960 8640344181 5981362977 4771309960

5187072113 4999999837 2978049951 0597317328 1609631859

5024459455 3469083026 4252230825 3344685035 2619311881

7101000313 7838752886 5875332083 8142061717 7669147303

5982534904 2875546873 1159562863 8823537875 9375195778

1857780532 1712268066 1300192787 6611195909 2164201989
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -