Complex Number Multiplication

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Complex Number Multiplication相关的知识,希望对你有一定的参考价值。

public class ComplexNumberMultiplicationSolution {
    public static String complexNumberMultiply(String a, String b) {
        int p1 = Integer.parseInt(a.split("\\+")[0]);
        int n1 = Integer.parseInt(a.split("\\+")[1].split("i")[0]);
        int p2 = Integer.parseInt(b.split("\\+")[0]);
        int n2 = Integer.parseInt(b.split("\\+")[1].split("i")[0]);
        int p = p1 * p2 - n1 * n2;
        int n = p1 * n2 + p2 * n1;
        String strP = String.valueOf(p);
        String strN = String.valueOf(n);
        System.out.println(p1);
        System.out.println(n1);
        System.out.println(p2);
        System.out.println(n2);
        System.out.println(strP + "+" + strN + "i");
        return null;
    }

    public static void main(String[] args) {
        ComplexNumberMultiplicationSolution complexNumberMultiplicationSolution = new ComplexNumberMultiplicationSolution();
        complexNumberMultiplicationSolution.complexNumberMultiply("1+2i", "3+4i");
    }
}

 

以上是关于Complex Number Multiplication的主要内容,如果未能解决你的问题,请参考以下文章

537. Complex Number Multiplication

537. Complex Number Multiplication

537. Complex Number Multiplication

537. Complex Number Multiplication

Leetcode537 Complex Number Multiplication Java实现

python 变量类型 number