我编写了一个程序,主要是判定一个四边形是否为平行四边形,可运行时出现错误,麻烦各位帮忙看下.
import java.io.*;public class Vector2D
{
private float x;
private float y;
public Vector2D() {}
public Vector2D(float a,float b)
{
x=a;
y=b;
}
public static void main(String argv[])
{
Vector2D m1=new Vector2D(1,1);
Vector2D m2=new Vector2D(3,1);
Vector2D m3=new Vector2D(2,2);
Vector2D m4=new Vector2D(4,2);
if((m1.x*m2.y=m2.x*m1.y)&&(m3.x*m4.y=m4.x*m3.y))
System.out.println("the quadrangle is a parallel quadrangle");
else
System.out.println("the quadrangle is not a parallel quadrangle");
}
}错误提示在"if((m1.x*m2.y=m2.x*m1.y)&&(m3.x*m4.y=m4.x*m3.y))" 之中出现unexpected type
import java.io.*;public class Vector2D
{
private float x;
private float y;
public Vector2D() {}
public Vector2D(float a,float b)
{
x=a;
y=b;
}
public static void main(String argv[])
{
Vector2D m1=new Vector2D(1,1);
Vector2D m2=new Vector2D(3,1);
Vector2D m3=new Vector2D(2,2);
Vector2D m4=new Vector2D(4,2);
if((m1.x*m2.y=m2.x*m1.y)&&(m3.x*m4.y=m4.x*m3.y))
System.out.println("the quadrangle is a parallel quadrangle");
else
System.out.println("the quadrangle is not a parallel quadrangle");
}
}错误提示在"if((m1.x*m2.y=m2.x*m1.y)&&(m3.x*m4.y=m4.x*m3.y))" 之中出现unexpected type
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货