import java.io.*;
import java.awt.geom.Point2D;
public class KeyIn {
public static void main(String[] args) throws IOException {
BufferedReader keyin;
keyin = new BufferedReader(new InputStreamReader(System.in));
double p1a, p1b, p2a, p2b, p3a, p3b;
System.out.println("keyin p1a: ");
String n1 = keyin.readLine();
p1a = Double.parseDouble(n1);
System.out.println("keyin p1b: ");
String e1 = keyin.readLine();
p1b = Double.parseDouble(e1);
System.out.println("keyin p2a: ");
String n2 = keyin.readLine();
p2a = Double.parseDouble(n2);
System.out.println("keyin p2b: ");
String e2 = keyin.readLine();
p2b = Double.parseDouble(e2);
System.out.println("keyin p3a: ");
String n3 = keyin.readLine();
p3a = Double.parseDouble(n3);
System.out.println("keyin p3b: ");
String e3 = keyin.readLine();
p3b = Double.parseDouble(e3);
Point2D.Double p1 = new Point2D.Double(p1a, p1b);
Point2D.Double p2 = new Point2D.Double(p2a, p2b);
Point2D.Double p3 = new Point2D.Double(p3a, p3b);
System.out.println("P1到P2的距離: " + p1.distance(p2));
System.out.println("P2到P3的距離: " + p2.distance(p3));
}
}
2007年11月9日 星期五
第四題
import java.awt.geom.Point2D;
class diastcomput {
public static void main (String args[]) {
Point2D.Double p1=new Point2D.Double(2779404.96,374361.55);
Point2D.Double p2=new Point2D.Double(2780364.19,372490.97);
Point2D.Double p3=new Point2D.Double(371679.98,2781665.63);
Point2D.Double p4=new Point2D.Double(2781484.36,371549.16);
Point2D.Double p5=new Point2D.Double(2782161.45,371901.26);
System.out.println("p1到P2距離: "+ p1.distance(p2));
System.out.println("p2到P3距離: "+ p2.distance(p3));
System.out.println("p3到P4距離: "+ p3.distance(p4));
System.out.println("p4到P5距離: "+ p4.distance(p5));
System.out.println("p5到P6距離: "+ p5.distance(p2));
}
}
class diastcomput {
public static void main (String args[]) {
Point2D.Double p1=new Point2D.Double(2779404.96,374361.55);
Point2D.Double p2=new Point2D.Double(2780364.19,372490.97);
Point2D.Double p3=new Point2D.Double(371679.98,2781665.63);
Point2D.Double p4=new Point2D.Double(2781484.36,371549.16);
Point2D.Double p5=new Point2D.Double(2782161.45,371901.26);
System.out.println("p1到P2距離: "+ p1.distance(p2));
System.out.println("p2到P3距離: "+ p2.distance(p3));
System.out.println("p3到P4距離: "+ p3.distance(p4));
System.out.println("p4到P5距離: "+ p4.distance(p5));
System.out.println("p5到P6距離: "+ p5.distance(p2));
}
}
訂閱:
文章 (Atom)