码迷,mamicode.com
首页 > 其他好文 > 详细

leetcode537

时间:2017-04-28 16:07:39      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:int   number   ring   get   lex   public   ref   result   tle   

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

标签:int   number   ring   get   lex   public   ref   result   tle   

原文地址:http://www.cnblogs.com/asenyang/p/6781588.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!