|

楼主 |
发表于 2023-1-27 21:41
|
显示全部楼层
Private Sub Command1_Click()
'求完美长方体的程序其中g和d是整数,e和f不一定是整数
Dim a, b, c, r
a1 = Val(Text1)
r = 1
Do While r <= a1
a = 1
Do While a <= a1
b = 1
Do While b <= a1
c = 1
Do While c <= a1
g = r * 4
x = a ^ 2 + b ^ 2 + c ^ 2
d = a ^ 2 + b ^ 2
e = b ^ 2 + c ^ 2
f = c ^ 2 + a ^ 2
If x = g ^ 2 And InStr(Sqr(d), ".") = 0 Then
s = s + 1
s22 = s22 & " /g=" & g & " a=" & a & " b=" & b & " c=" & c & vbCrLf
Else
s = s
End If
c = c + 1
Loop
b = b + 1
Loop
a = a + 1
Loop
r = r + 1
Loop
If Val(s) > 0 Then
Text2 = "输入 " & a1 & ",内有 " & s & " 组解(g和d是对的,e和f可能不是整数):" & vbCrLf & s22
Else
Text2 = "无解"
End If
End Sub
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
End Sub
朋友告诉我:4x+1型的奇数或4x型的偶数大多可以拆分成3个平方数的和 |
|