注意-0.005~0.005这段范围的取符号;
比如B<0&&B>-0.005,此时应该输出+0.00,如果直接判断B的正负会输出-0.00
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include<iomanip>
using namespace std;
const int maxn = 10010;
int main() {
double r1, p1, r2, p2;
cin >> r1 >> p1 >> r2 >> p2;
double A, B;
A = r1 * r2*(cos(p1)*cos(p2) - sin(p1)*sin(p2));
B = r1*r2*(cos(p1)*sin(p2) + sin(p1)*cos(p2));
if (fabs(A)<0.005)
{
cout << "0.00";
}else cout << fixed << setprecision(2) << A;
if (fabs(B)<0.005)cout << "+0.00i";
else
{
if (B>0)
cout << '+';
cout << fixed << setprecision(2) << B << 'i' << endl;
}
return 0;
}