170以内阶乘表(Factorial list up to 170)
2008-04-08 15:25
330 查看
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//Display a factorial list up to 170
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//Java How to Program, 5/e, Exercise 5.8
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import javax.swing.*;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public class FactorialList {
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public static void main(String args[])
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
double factorial;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int number;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
String Number;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Number=JOptionPane.showInputDialog("Enter a nonegative integer");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
number=Integer.parseInt(Number);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
JTextArea outputArea= new JTextArea(20,30);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
JScrollPane scroller= new JScrollPane(outputArea);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
outputArea.setText("n! /tResult ");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int counter=1;counter<=number;counter++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
factorial=1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i=1;i<=counter;i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
factorial*=i;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
outputArea.append(counter+"! /t"+factorial+" /n");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
JOptionPane.showMessageDialog(null, scroller,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
"Factorial Calculation",JOptionPane.INFORMATION_MESSAGE);}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
相关文章推荐
- About UID and How to autostart an application on boot up in 3rd- Startup List Management API
- LINQ标准查询操作符(四)—AsEnumerable,Cast,OfType,ToArray,ToDictionary,ToList,ToLookup,First,Last,ElementAt
- LINQ标准查询操作符(四) —AsEnumerable,Cast,OfType,ToArray,ToDictionary,ToList,ToLookup,First,Last,ElementAt
- 精彩控件件源码(3)-ImageListPopup, a C# class which pops up a window to select an image from an image list
- LINQ标准查询操作符(四) —AsEnumerable,Cast,OfType,ToArray,ToDictionary,ToList,ToLookup,First,Last,ElementAt
- 鲜为人知的奇妙函数List的ToLookup(LINQ Extension Method)
- 12以内阶乘、自然对数e及e的x次方的计算(Factorial)
- 关于android SDK安装Failed to fetch URL http://dl-ssl.google.com/android/repository/addons_list-1.xml出错
- Project configuration is not up-to-date with pom.xml
- to do list
- LeetCode OJ - Convert Sorted List to Binary Search Tree
- 109. Convert Sorted List to Binary Search Tree
- 解决“List is a raw type. References to generic type List”提示的问题
- [C#.Net&Linq]LINQ to Object 学习笔记(资料群组GroupBy、ToLookup、ToDictionary)
- Failed to fetch URL http://dl-ssl.google.com/android/repository/addons_list-1.xml 解決方法
- [LeetCode109]Convert Sorted List to Binary Search Tree
- 泛型中字符串转集合,(T)object,typeOf(T),LIst<T> xxx<T>();c# stringtolist
- Failed to fetch URL https://dl-ssl.google.com/android/repository/addons_list-2.xml, reason: Connect
- 【我的Android进阶之旅】解决SVN Cleanup错误: Failed to run the WC DB work queue associated with
- 100以内的阶乘计算方法