1 import java.util.Scanner; 2 3 public class Main { 4 public static void main(String[] args) { 5 Scanner sc = new Scanner(System.in); 6 double R1, P1, R2, P2; 7 R1 = sc.nextDouble(); 8 P1 = sc.nextDouble(); 9 R2 = sc.nextDouble(); 10 P2 = sc.nextDouble(); 11 double A1, B1, A2, B2, A3, B3; 12 A1 = R1 * Math.cos(P1); 13 B1 = R1 * Math.sin(P1); 14 A2 = R2 * Math.cos(P2); 15 B2 = R2 * Math.sin(P2); 16 A3 = A1 * A2 - B1 * B2; 17 B3 = A1 * B2 + A2 * B1; 18 if (A3 > -0.005 && A3 < 0.005) { 19 System.out.print("0.00"); 20 } else { 21 System.out.printf("%.2f", A3); 22 } 23 if (B3 > -0.005 && B3 < 0.005) { 24 System.out.println("+0.00i"); 25 } else { 26 System.out.printf("%+.2fi", B3); 27 } 28 sc.close(); 29 } 30 }
标签:形式,System,A3,复数,B3,sc,虚数,Math From: https://www.cnblogs.com/wzyxslx/p/18582195