勾股数列表(Find Pythagorean Triples)
来源:互联网 发布:知乎口腔溃疡 冰硼散 编辑:程序博客网 时间:2024/06/08 04:44
//Find Pythagorean Triples within 500
//Java how to program, 5/e, Exercise 5.17
import javax.swing.*;
public class PythagoreanTriples {
public static void main (String arg[])
{
boolean guard;
int counter=1, number;
String Number;
Number=JOptionPane.showInputDialog("Enter the limit number:");
number=Integer.parseInt(Number);
JTextArea output=new JTextArea(17,20);
JScrollPane scroller=new JScrollPane(output);
output.setText("N1/t N2/tN3/t");
for (int i=1;i<=number;i++)
{for (int j=i+1;j<=number;j++)
{for (int k=j+1;k<=number;k++)
{guard=i*i+j*j==k*k;
if (guard)
{output.append(i+"/t "+j+" /t"+k+" /t");
counter++;}
}
}
}
output.append(" Total Pythagorean Triples number:"+counter);
JOptionPane.showMessageDialog(null, scroller,"Pythagorean Triples",
JOptionPane.INFORMATION_MESSAGE);
}
}
//Java how to program, 5/e, Exercise 5.17
import javax.swing.*;
public class PythagoreanTriples {
public static void main (String arg[])
{
boolean guard;
int counter=1, number;
String Number;
Number=JOptionPane.showInputDialog("Enter the limit number:");
number=Integer.parseInt(Number);
JTextArea output=new JTextArea(17,20);
JScrollPane scroller=new JScrollPane(output);
output.setText("N1/t N2/tN3/t");
for (int i=1;i<=number;i++)
{for (int j=i+1;j<=number;j++)
{for (int k=j+1;k<=number;k++)
{guard=i*i+j*j==k*k;
if (guard)
{output.append(i+"/t "+j+" /t"+k+" /t");
counter++;}
}
}
}
output.append(" Total Pythagorean Triples number:"+counter);
JOptionPane.showMessageDialog(null, scroller,"Pythagorean Triples",
JOptionPane.INFORMATION_MESSAGE);
}
}
- 勾股数列表(Find Pythagorean Triples)
- #368 C. Pythagorean Triples 勾股数
- Codeforces #368(Div.2)C. Pythagorean Triples【勾股数】
- Pythagorean Triples
- codeforces 707 c Pythagorean Triples 数论+勾股数
- 勾股定理(Pythagorean Triples,cf 707C)
- Codeforces 707C Pythagorean Triples(数学)
- codeforces 707C Pythagorean Triples(数学)
- codeforces 707-C. Pythagorean Triples(数学)
- 使用三重嵌套循环暴力查找勾股数及不同算法的比较(Pythagorean Triples)
- Codeforces Round #368 (Div. 2)(C. Pythagorean Triples 勾股数规律)
- Codeforces Round #368 (Div. 2) C Pythagorean Triples(构造勾股数)
- [codeforces707C]Pythagorean Triples
- Codeforce707 C. Pythagorean Triples
- C. Pythagorean Triples
- C. Pythagorean Triples
- [Codeforces #368 (Div. 2) Pythagorean Triples] 数学:勾股数
- Codeforces Round #368 (Div. 2) C. Pythagorean Triples (本原勾股数)
- 关于用vc写outlook add-in
- 基于 SOA 的区域电子政务解决方案之项目背景
- 1.1从Hello Qt开始
- 编程语言你怎么选?
- Class Loader
- 勾股数列表(Find Pythagorean Triples)
- 获得汉字字符串拼音首字母 C#版
- hibernate 3 映射学习
- “只弯一次腰”的故事
- SQL Server 通配符(用于Like 查询)
- string数组类型转换为int数组(数组类型之间的转换)
- 1.2连接信号和响应函数
- 如果你电脑上安装的是IE7 一个很容易的方法
- ASP.NET获取IP和电脑用户名