📄 ch6_e6_19.java
字号:
public class ch6_e6_19
{
public static void main(String args[])
{
if(args.length<2)
{
System.out.println("运行本程序应该提供两个整型命令行参数"
+ "例如:\n java ch6_e6_19 1 1000");
System.exit(0);
}
try
{
int floor,ceiling,temp,count=0;
floor = Integer.parseInt(args[0]);
ceiling = Integer.parseInt(args[1]);
if(floor > ceiling)
{
temp = floor;
floor = ceiling;
ceiling = temp;
}
for(int i=floor; i<ceiling; i++)
{
int y=0;
for(int j=1; j<i; j++)
{
if( i%j == 0)
y += j;
}
if( y == i )
{
System.out.print( i + "\t" );
count++;
if( count%6 == 0)
System.out.println();
}
}
}
catch(NumberFormatException nfe)
{
System.out.println(nfe.toString());
System.out.println("命令行参数应为整型,例如"
+ "\n java ch6_e6_19 1 1000");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -