5-8.txt
来自「jsp常用实例讲解」· 文本 代码 · 共 43 行
TXT
43 行
class doRect
{
public static void main(String args[])
{
int w=Integer.valueOf(args[0]).intValue();
int h=Integer.valueOf(args[1]).intValue();
Rectangle myrect=new Rectangle(w,h);
myrect.drawRect();
}
class Rectangle
{
int width,height,area;
public Rectangle(int w,int h)
{
width=w;
height=h;
area=getArea(w,h);
}
protected int getArea(int w,int h)
{
int a;
a=w*h;
return a;
}
public void drawRect()
{
int i,j;
for(i=width;i>0;i--)
System.out.print("#");
System.out.print("")
for(i=height-2;i>0;i--)
{
System.out.print("#");
for(j=width-2;i>0;j--)
System.out.print("");
System.out.print("#");
}
for(i=width;i>0;i--)
System.out.print("#");
System.out.print("");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?