#include<math.h>
#include<iostream>
using namespace std;
int main() {
double R1, P1, R2, P2, tmp1,tmp2;
scanf("%lf %lf %lf %lf", &R1, &P1, &R2, &P2);
tmp1 = R1 * cos(P1)*R2*cos(P2) - R1 * sin(P1)*R2*(sin(P2));
if (tmp1 > -0.005&&tmp1 < 0)tmp1 = 0;
printf("%.2f", tmp1);
tmp2 = R1 * cos(P1)*R2*sin(P2) + R2 * cos(P2)*R1*sin(P1);
if (tmp2 > -0.005&&tmp2 < 0)tmp2 = 0;
tmp2 >= 0 ? printf("+%.2fi", tmp2) : printf("%.2fi", tmp2);
return 0;
}
测试点2,3主要问题就是对-0.00的处理。
因为是用的%.2f,也就是常说的四舍五入,那么问题是-0.0044四舍五入以后是-0.00,但是带了负号,所以需要手动归零。