VERSION 5.00
Begin VB.Form Form1
AutoRedraw = -1 'True
BorderStyle = 1 'Fixed Single
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 45
ClientTop = 330
ClientWidth = 4680
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "退出"
Height = 375
Left = 2880
TabIndex = 3
Top = 2760
Width = 855
End
Begin VB.CommandButton Command1
Caption = "计算"
Height = 375
Left = 1560
TabIndex = 2
Top = 2760
Width = 855
End
Begin VB.TextBox Text1
Height = 270
Left = 2040
TabIndex = 1
Top = 1320
Width = 1095
End
Begin VB.Label Label2
AutoSize = -1 'True
Height = 180
Left = 1920
TabIndex = 4
Top = 1800
Width = 90
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "N="
Height = 180
Left = 1800
TabIndex = 0
Top = 1320
Width = 180
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Option ExplicitDim nCount As IntegerPrivate Sub Command1_Click()
Dim N As LongIf Text1 = "" Then
N = 8
Else
N = Val(Text1)
End IfCal_N NEnd SubPrivate Sub Command2_Click()
End
End SubPrivate Sub Form_Load()Form1.Width = 800 * 15
Form1.Height = 600 * 15
Form1.ScaleMode = vbPixels
Form1.Left = (Screen.Width - Form1.Width) / 2
Form1.Top = (Screen.Height - Form1.Height) / 2Command1.Left = 350
Command1.Top = 500
Command2.Left = 450
Command2.Top = 500
End Sub
Private Sub Cal_N(ByVal N As Long)
Dim i As Long
Dim j As Long
Dim k As Long
Dim X As Long
Dim Y As Long
Dim Z As Long
Dim xRangeMin As Long
Dim xRangeMax As Long
Dim yRangeMin As Long
Dim yRangeMax As Long
Dim Nxy As Long
Dim xy_N As LongnCount = 0
xRangeMax = N * 3 / 4
xRangeMin = N / 4 For i = xRangeMin To xRangeMax
If N <> 4 * i Then
yRangeMax = i * N / (i + i + i + i - N) * 2
'yRangeMin = i * N / (i + i + i + i - N)
For j = i To yRangeMax
Nxy = N * i * j
xy_N = 4 * i * j - N * i - N * j
If xy_N > 0 Then
` If Nxy Mod xy_N = 0 Then
Open "d:\N=" & N & ".txt" For Append As #1
Print #1, i & " " & j & " " & Nxy / xy_N & Chr(13)
Print i & " " & j & " " & Nxy / xy_N
Close #1
nCount = nCount + 1
End If
End If
Next j
End If
Next i
Label2.Caption = "总共得到" & nCount & "组结果。"
End Sub我要的是求出4/n=1/x+1/y+1/z的所有的正整数的解,x,y,z之间的排序算一个解,
例如:4/8=1/6+1/6+1/6=1/5+1/10+1/10=1/4+1/8+1/8=.....=....
这个n=8时有10组解;上面的程序我试n=500的行,而n=2000的时候回益出。请高手们,教我怎么改,谢谢!
Begin VB.Form Form1
AutoRedraw = -1 'True
BorderStyle = 1 'Fixed Single
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 45
ClientTop = 330
ClientWidth = 4680
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "退出"
Height = 375
Left = 2880
TabIndex = 3
Top = 2760
Width = 855
End
Begin VB.CommandButton Command1
Caption = "计算"
Height = 375
Left = 1560
TabIndex = 2
Top = 2760
Width = 855
End
Begin VB.TextBox Text1
Height = 270
Left = 2040
TabIndex = 1
Top = 1320
Width = 1095
End
Begin VB.Label Label2
AutoSize = -1 'True
Height = 180
Left = 1920
TabIndex = 4
Top = 1800
Width = 90
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "N="
Height = 180
Left = 1800
TabIndex = 0
Top = 1320
Width = 180
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Option ExplicitDim nCount As IntegerPrivate Sub Command1_Click()
Dim N As LongIf Text1 = "" Then
N = 8
Else
N = Val(Text1)
End IfCal_N NEnd SubPrivate Sub Command2_Click()
End
End SubPrivate Sub Form_Load()Form1.Width = 800 * 15
Form1.Height = 600 * 15
Form1.ScaleMode = vbPixels
Form1.Left = (Screen.Width - Form1.Width) / 2
Form1.Top = (Screen.Height - Form1.Height) / 2Command1.Left = 350
Command1.Top = 500
Command2.Left = 450
Command2.Top = 500
End Sub
Private Sub Cal_N(ByVal N As Long)
Dim i As Long
Dim j As Long
Dim k As Long
Dim X As Long
Dim Y As Long
Dim Z As Long
Dim xRangeMin As Long
Dim xRangeMax As Long
Dim yRangeMin As Long
Dim yRangeMax As Long
Dim Nxy As Long
Dim xy_N As LongnCount = 0
xRangeMax = N * 3 / 4
xRangeMin = N / 4 For i = xRangeMin To xRangeMax
If N <> 4 * i Then
yRangeMax = i * N / (i + i + i + i - N) * 2
'yRangeMin = i * N / (i + i + i + i - N)
For j = i To yRangeMax
Nxy = N * i * j
xy_N = 4 * i * j - N * i - N * j
If xy_N > 0 Then
` If Nxy Mod xy_N = 0 Then
Open "d:\N=" & N & ".txt" For Append As #1
Print #1, i & " " & j & " " & Nxy / xy_N & Chr(13)
Print i & " " & j & " " & Nxy / xy_N
Close #1
nCount = nCount + 1
End If
End If
Next j
End If
Next i
Label2.Caption = "总共得到" & nCount & "组结果。"
End Sub我要的是求出4/n=1/x+1/y+1/z的所有的正整数的解,x,y,z之间的排序算一个解,
例如:4/8=1/6+1/6+1/6=1/5+1/10+1/10=1/4+1/8+1/8=.....=....
这个n=8时有10组解;上面的程序我试n=500的行,而n=2000的时候回益出。请高手们,教我怎么改,谢谢!
解决方案 »
- 问一个WINSOCK的非正常退出的处理方式问题..高手帮帮忙哈~~
- 怎么在VB程序中新建一个 ftp站点的虚拟目录
- 100分相求vb串口问题
- 自动换行 查找 替换 这些功能要怎么实现啊
- 紧急求救:如何控制文本框中的光标位置并在适当的位置输出回车符?
- 请教高手,如何获取自定义控件中的所有用到的控件!
- 请推荐用VB6.0+SQL(ADO)编程的书、网站?
- VB怎样处理通信时发生帧丢失问题,分不够再加,急!急!急!
- 工资管理系统的报表怎么设计啊
- 谁能帮我解决个数学问题?用编程的方法接二阶微分方程的数值解
- CSDN的结贴率太低,好象不是这样的.各位........
- 关于vb读取excel数据的重大问题
你那个表达时:Nxy = N * i * j计算的结果是2,148,288,000当然要溢出!
Print i & " " & j & " " & Nxy / xy_N *1000另有一个建议:
将Open "d:\N=" & N & ".txt" For Append As #1这一句放在循环体前,将Close #1放在循环体后面