<p>A <a href="https://en.wikipedia.org/wiki/Complex_number" target="_blank">complex number</a> can be represented as a string on the form <code>&quot;<strong>real</strong>+<strong>imaginary</strong>i&quot;</code> where:</p>

<ul>
	<li><code>real</code> is the real part and is an integer in the range <code>[-100, 100]</code>.</li>
	<li><code>imaginary</code> is the imaginary part and is an integer in the range <code>[-100, 100]</code>.</li>
	<li><code>i<sup>2</sup> == -1</code>.</li>
</ul>

<p>Given two complex numbers <code>num1</code> and <code>num2</code> as strings, return <em>a string of the complex number that represents their multiplications</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> num1 = &quot;1+1i&quot;, num2 = &quot;1+1i&quot;
<strong>Output:</strong> &quot;0+2i&quot;
<strong>Explanation:</strong> (1 + i) * (1 + i) = 1 + i2 + 2 * i = 2i, and you need convert it to the form of 0+2i.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> num1 = &quot;1+-1i&quot;, num2 = &quot;1+-1i&quot;
<strong>Output:</strong> &quot;0+-2i&quot;
<strong>Explanation:</strong> (1 - i) * (1 - i) = 1 + i2 - 2 * i = -2i, and you need convert it to the form of 0+-2i.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>num1</code> and <code>num2</code> are valid complex numbers.</li>
</ul>

class Solution {
public:
    string complexNumberMultiply(string s, string t) {
        int a=0,b=0,x=0,y=0;
        int idx=0;
        bool isneg=false;
        while(s[idx]!='+')
        {
            if(s[idx]=='-')
            {
                isneg=true;
            }
            else if(s[idx]>='0' and s[idx]<='9')
            {
                int n=s[idx]-'0';
                a=a*10+n;
            }
            idx++;
        }
        if(isneg==true)
        {
            a=a*(-1);
        }
        isneg=false;
        idx++;
        while(idx<s.length())
        {
            if(s[idx]=='-')
            {
                isneg=true;
            }
            else if(s[idx]>='0' and s[idx]<='9')
            {
                int n=s[idx]-'0';
                b=b*10+n;
            }
            idx++;
        }
        if(isneg==true)
        {
            b=b*-1;
        }
        isneg=false;
        idx=0;
        while(t[idx]!='+')
        {
            if(t[idx]=='-')
            {
                isneg=true;
            }
            else if(t[idx]>='0' and t[idx]<='9')
            {
                int n=t[idx]-'0';
                x=x*10+n;
            }
            idx++;
        }
        if(isneg==true)
        {
            x=x*(-1);
        }
        isneg=false;
        idx++;
        while(idx<t.length())
        {
            if(t[idx]=='-')
            {
                isneg=true;
            }
            else if(t[idx]>='0' and t[idx]<='9')
            {
                int n=t[idx]-'0';
                y=y*10+n;
            }
            idx++;
        }
        if(isneg==true)
        {
            y=y*-1;
        }
        int c=(a*x)-(b*y);
        int d=(a*y)+(b*x);
        string ans="";
        ans.append(to_string(c));
        ans.push_back('+');
        ans.append(to_string(d));
        ans.push_back('i');
        return ans;
    }
};
7200