1/5=1/a+1/b+1/c+1/d,abcd是互不相同正整数,求a+b+c+d的最小值,请求编一个程序找出答案,vb或c语言
最好能显示答案看看,可以abcd排个序,他们的范围在6-84之间6〈a〈b〈c〈d〈84,且a〈20,d〉20...
最好能显示答案看看,可以abcd排个序,他们的范围在6-84之间
6〈a〈b〈c〈d〈84,且a〈20,d〉20 展开
6〈a〈b〈c〈d〈84,且a〈20,d〉20 展开
2个回答
展开全部
for (int a = 6; a < 20; a++) {
for(int b = a + 1; b <84; b ++) {
for(int c = b + 1; c < 84; c++) {
for(int d = c + 1; d < 84; d ++) {
if(d > 20 && (double)1/5==(double)1/a+(double)1/b+(double)1/c+(double)1/d)
printf("a = %d, b = %d, c = %d, d = %d\n", a, b, c, d);
}
}
}
}
}
追问
最后运行答案是多少?我想知道答案啊
追答
哦,没看见个还有球最小值呢
2015-11-16
展开全部
Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Integer, d As Integer
Dim a1 As Integer, b1 As Integer, c1 As Integer, d1 As Integer
Dim sum As Integer, sum1 As Integer, k As Integer
sum1 = 320
For a = 1 To 20
For b = a + 1 To 82
For c = b + 1 To 83
k = IIf(c + 1 > 20, c + 1, 20)
For d = k To 84
If 1 / a + 1 / b + 1 / c + 1 / d = 1 / 5 Then
sum = a + b + c + d
If sum < sum1 Then
sum1 = sum
a1 = a
b1 = b
c1 = c
d1 = d
End If
End If
Next d
Next c
Next b
Next a
MsgBox "满足条件的数为:" & Str(a1) & Str(b1) & Str(c1) & Str(d1)
End Sub
追问
运行结果能看一看吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询