1 4
5 3
2 2 import java.util.Scanner;
public class test1
{
private static final int x2 = 0;
public static void main(String[] args )
{
Scanner sc=new Scanner(System.in);
int x1,y1,w,h,x,y,area;
double a=0;
x1=sc.nextInt();
y1=sc.nextInt();
w=sc.nextInt();
h=sc.nextInt();
x=sc.nextInt();
y=sc.nextInt();
Rectangle p1=new Rectangle(x1,y1,w,h);
a= p1.getArea(w, h);
System.out.printf("area=%.1f\n",a);//引用函数1
p1.Contains(x, y);
}
static class Rectangle
{
public int x,y,w,h;
public double getArea(double w,double h)
{
double s; //求面积,并返回s
s=w*h;
return s;
}
public Rectangle(int x1,int y1,int x2,int y2)
{
x=x1;y=y1;w=x2;h=y2; //定义长方形
}
public void Contains(int a,int b)
{
if(this.x<a&&this.y>b) //判断点是否在长方形内
System.out.println("("+a+","+b+")"+"在长方形("+this.x+","+this.y+"),"+"w="+w+","+"h="+(int)h+"内");
else
System.out.println("("+a+","+b+")"+"在长方形("+this.x+","+this.y+"),"+"w="+w+","+"h="+(int)h+"外");
}
}
} |