毕达哥拉斯三倍 [英] Pythagorean triples

查看:95
本文介绍了毕达哥拉斯三倍的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VB .NET类中,并且其中一个任务是使用循环来生成所有毕达哥拉斯三元组的列表,其中legA和legB <100且斜边< 200,然后将此列表放入列表框。

到目前为止我已经这样做了:

展开 | 选择 | 换行 | 行号

解决方案

您需要重新考虑您的For循环,以便您不会有任何重复。 --Sam



你需要重新考虑你的For循环,这样你就不会有任何重复。 --Sam



很明显,但是你能指出一些更重要的方向吗?我(正如我顺便提到的那样)一直绞尽脑汁试图想出一个解决方案,但我感到很茫然(通常这些事情很快就会发生)。


感谢你回复和任何未来的帮助(当然,这都属于道德范围)。



很明显,但是你可以指点我吗?一些东西的方向更加实质?我(正如我顺便提到的那样)一直绞尽脑汁试图想出一个解决方案,但我感到很茫然(通常这些事情很快就会发生)。


感谢你回复和任何未来的帮助(当然,这都属于道德范围)。



当你接受时,我正在尝试(作为一名教师)让你想到如何解决问题。还有一些想法:(1)你真的需要三个循环吗?从trig,你知道hyp平方=其他两边的平方和。 (2)减少对小的限制,并写出For循环的变量,这样你就可以看到如何使迭代只考虑一次可能性;例如,当LeqA For循环开启时,是否有任何理由在1处启动LegB循环?你还没盖过那个案子吗?保持微笑! --Sam


I am in a VB .NET class, and one of the assignments is to use loops to generate a list of all the pythagorean triples where legA and legB <100 and hypotenuse < 200, and then put this list into a listbox.
I have done this so far:

Expand|Select|Wrap|Line Numbers

解决方案

You need to rethink your For loops so that you won''t have any duplicates. --Sam


You need to rethink your For loops so that you won''t have any duplicates. --Sam

Clearly, but could you point me in the direction of something somewhat more substantial? I have (as I mentioned in passing) been racking my brain trying to come up with a solution, but am at a loss (normally these things come pretty quickly).

Thanks for the reply and any future help (that, of course, falls within the limits of morality).


Clearly, but could you point me in the direction of something somewhat more substantial? I have (as I mentioned in passing) been racking my brain trying to come up with a solution, but am at a loss (normally these things come pretty quickly).

Thanks for the reply and any future help (that, of course, falls within the limits of morality).

As you picked up, I''m trying (as a teacher myself) to make you think of how to solve the problem. A couple more ideas: (1) Do you really need three loops? From trig, you know that the hyp squared = the sum of the squares of the other two sides. (2)Reduce you side limits to something small and write out the variables of the For loop, so that you can see how to make the iterations only cove the possibilities once; for example, when the LeqA For loop is on 2, is there any reason to start the LegB loop at 1? Haven''t you already covered that case? Keep smiling! --Sam


这篇关于毕达哥拉斯三倍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆