Relative Content

Tag Archive for c++stringsumtostringcomplex-numbers

Why is this sum always giving 4802?

class Solution { public: string complexNumberMultiply(string num1, string num2) { string ans, stemp1, stemp2; if (num1[2] != ‘-‘ && num2[2] != ‘-‘) { int temp1 = num1[0] * num2[0] + (-1 * num1[2] * num2[2]); int temp2 = num1[0] * num2[2] + num1[2] * num2[0]; stemp1 = to_string(temp1); stemp2 = to_string(temp2); } else { int […]