https://leetcode.com/problems/complex-number-multiplication/description/
题解:这道题只要了解复数是怎么运算就好了
class Solution {
public String complexNumberMultiply(String a, String b) {
//a1,a2是a的实部和虚部,b1,b2是b的实部和虚部
int a1, a2, b1, b2;
a1 = Integer.valueOf(a.substring(0, a.indexOf("+")));
a2 = Integer.valueOf(a.substring(a.indexOf("+")+1, a.length()-1));
b1 = Integer.valueOf(b.substring(0, b.indexOf("+")));
b2 = Integer.valueOf(b.substring(b.indexOf("+")+1, b.length()-1));
return (a1*b1-a2*b2)+"+"+(a1*b2+b1*a2)+"i";
}
}