首页 > 代码库 > leetcode537

leetcode537

public class Solution {
    public string ComplexNumberMultiply(string a, string b) {
        var aryA = a.Split(+);
            var aryB = b.Split(+);

            var shiA = Convert.ToInt32(aryA[0]);
            var xuA = Convert.ToInt32(aryA[1].Substring(0, aryA[1].Length - 1));

            var shiB = Convert.ToInt32(aryB[0]);
            var xuB = Convert.ToInt32(aryB[1].Substring(0, aryB[1].Length - 1));

            var shi1 = shiA * shiB;
            var shi2 = xuA * xuB * (-1);
            var shi = shi1 + shi2;

            var xu1 = shiA * xuB;
            var xu2 = xuA * shiB;
            var xu = xu1 + xu2;

            var result = shi + "+" + xu + "i";

            return result;
    }
}

https://leetcode.com/problems/complex-number-multiplication/#/description

leetcode537