- 注册时间
- 2020-9-23
- 最后登录
- 1970-1-1
- 威望
- 星
- 金币
- 枚
- 贡献
- 分
- 经验
- 点
- 鲜花
- 朵
- 魅力
- 点
- 上传
- 次
- 下载
- 次
- 积分
- 615
- 在线时间
- 小时
|
楼主 |
发表于 2020-10-4 20:43:36
|
显示全部楼层
使用HugeCalc计算库手动求阶乘的代码可以这样写吗?
Private Sub cmdFactoriel_Click()
Dim hi1 As Long
Dim hi2 As Long
Dim hi3 As Long
Dim i As Long
Dim pStr As Long
Dim nStrLen As Long
Dim Str As String
Dim TempsUtilise As Single
QueryPerformanceCounter Counter0
hi1 = HI_new
hi2 = HI_new
hi3 = HI_new
QueryPerformanceCounter Counter1
HI_set_u32 hi1, 1
For i = 2 To CLng(txtNaturel.Text)
HI_mul_u32 hi1, hi1, i
Next i
QueryPerformanceCounter Counter2
TempsUtilise = (Counter2 - Counter1) / Frequency
txtTempsUtilise.Text = TempsUtilise
pStr = HI_getStr(hi1, 0, nStrLen)
L_SetWindowText txtFactoriel1.hWnd, pStr
HI_delete hi1
HI_delete hi2
HI_delete hi3
QueryPerformanceCounter Counter3
TempsUtilise = (Counter3 - Counter0) / Frequency
txtTempsUtilise2.Text = TempsUtilise
ShowErrorCode
End Sub
特别是
HI_mul_u32 hi1, hi1, i
语句会不会影响运算速度,前一个hi1有没有被删除? |
|