?? factors.java
字號:
import java.io.*;
/** 一個簡單的應用程序,用來說明continue語句的使用
* 程序功能:輸入一個整數(shù),求出它的所有因子
* @作者:尉哲明
* @日期:2001年5月 */
/** 類Factors */
public class Factors{
/** main()方法 */
public static void main( String args[] ) throws IOException
{
int n ;
//下面7行語句的作用是從鍵盤輸入n的值
InputStreamReader ir;
BufferedReader in;
ir=new InputStreamReader(System.in);
in=new BufferedReader(ir);
System.out.println("Input n is: ");
String s=in.readLine();
n=Integer.parseInt(s);
System.out.println("Factors of "+n+" :");
//下面用for循環(huán)結(jié)構(gòu)求n的所有因子
for(int i=1;i<=n;i++)
{
if(n%i!=0)
continue;//n%i!=0時,i不是n的因子,跳過打印語句回到循環(huán)起始。
System.out.print(i+" ");
}
System.out.print("\n");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -