文件名称:java3
介绍说明--下载内容均来自于网络,请自行研究使用
实验四:毕达哥拉斯三元组
实验目的:1.嵌套的for循环。
2.使用计数器控制的循环。
3.使用“强力(brute force)”来解决问题。
问题描述:直角三角形的各边长度都可以为整数。这组代表直角三角形各边的整型值称为
毕达哥拉斯三元组。这3条边必须满足如下关系:两条直角边的平方和等于斜边的平方。在1到500的范围内,找出所有适合于side1,side2和hypotenuse的整形毕达哥拉斯三元组。使用一个3层嵌套的for循环尝试所有可能的情况。该程序是“强力”计算的一个例子。在
更加高级的计算机科学课程中,你会学习到许多有趣的问题,这些问题只能运用“强力”手段予以解决,因为还没有找到其他的算法。注意:这里给出的示例输出只显示了17个毕达哥拉斯三元组,其实还有许多。
-Experiment 4: Pythagorean triples purpose of the experiment: a nested for loop. (2) using the cycle counter control. (3) using the strong (a brute force) to solve the problem. Problem Descr iption: right triangle the length of each side can be thought integers. This group represents the integer value of a right triangle each side is known as Pythagorean triples. The three sides must satisfy the following relationship: the square and the square of the hypotenuse is equal to two right angles to the edge. Within the range of 1-500 to identify all side1, side2 and hypotenuse plastic Pythagorean triples. Using a three-layer nested for loop to try all possible situations. The program is an example of " brute force" calculation. In the more advanced computer science courses, you will learn many interesting problems, these problems can only use " brute force" means to be resolved have not yet found the other algorithms. Note: The sample output shows only 17 Pythagorean triples
实验目的:1.嵌套的for循环。
2.使用计数器控制的循环。
3.使用“强力(brute force)”来解决问题。
问题描述:直角三角形的各边长度都可以为整数。这组代表直角三角形各边的整型值称为
毕达哥拉斯三元组。这3条边必须满足如下关系:两条直角边的平方和等于斜边的平方。在1到500的范围内,找出所有适合于side1,side2和hypotenuse的整形毕达哥拉斯三元组。使用一个3层嵌套的for循环尝试所有可能的情况。该程序是“强力”计算的一个例子。在
更加高级的计算机科学课程中,你会学习到许多有趣的问题,这些问题只能运用“强力”手段予以解决,因为还没有找到其他的算法。注意:这里给出的示例输出只显示了17个毕达哥拉斯三元组,其实还有许多。
-Experiment 4: Pythagorean triples purpose of the experiment: a nested for loop. (2) using the cycle counter control. (3) using the strong (a brute force) to solve the problem. Problem Descr iption: right triangle the length of each side can be thought integers. This group represents the integer value of a right triangle each side is known as Pythagorean triples. The three sides must satisfy the following relationship: the square and the square of the hypotenuse is equal to two right angles to the edge. Within the range of 1-500 to identify all side1, side2 and hypotenuse plastic Pythagorean triples. Using a three-layer nested for loop to try all possible situations. The program is an example of " brute force" calculation. In the more advanced computer science courses, you will learn many interesting problems, these problems can only use " brute force" means to be resolved have not yet found the other algorithms. Note: The sample output shows only 17 Pythagorean triples
(系统自动生成,下载前可以参看下载内容)
下载文件列表
java3.doc