題目
請輸入任意ax+by+c=0然後輸入座標判斷是否在直線上
package ch5;
import java.io.*;
public class ch5_7_3
{
public static void main(String args[])throws IOException
{
InputStreamReader in=new InputStreamReader(System.in);
BufferedReader buf=new BufferedReader(in);
int x,y,c,x1,y1;
String sx,sy,sc,sx1,sy1;
int l1;
sx=buf.readLine();
x=Integer.parseInt(sx);
sy=buf.readLine();
y=Integer.parseInt(sy);
sc=buf.readLine();
c=Integer.parseInt(sc);
sx1=buf.readLine();
x1=Integer.parseInt(sx1);
sy1=buf.readLine();
y1=Integer.parseInt(sy1);
System.out.println("直線方程式"+x+"x+("+y+"y)+("+c+")=0");
System.out.println("座標("+x1+","+y1+")");
l1=x1*x+y1*y+c;
if (l1==0)
System.out.println("這個點在直線上");
else
System.out.println("這個點不在直線上");
}
}
結果
2
-5
28
11
10
直線方程式2x+(-5y)+(28)=0
座標(11,10)
這個點在直線上
請先 登入 以發表留言。