Keywords:
double ,float,
AC CODE:
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
double r1,p1,r2,p2;
cin>>r1>>p1>>r2>>p2;
double a1,b1,a2,b2;
a1 = r1*(cos(p1)); b1 = r1*(sin(p1));
a2 = r2*(cos(p2)); b2 = r2*(sin(p2));
double a3,b3 ;
a3 = a1*a2 - b1*b2;
b3 = a1*b2+a2*b1;
/*输出复数的实部*/
if(a3 < 0 && a3 + 0.005 >=0){
printf("0.00");
}
else{
printf("%.2f",a3);
}
/*输出复数的虚部*/
if(b3 >= 0)
printf("+%.2fi",b3);
else if(b3 < 0 && b3+0.005 >=0){
printf("+0.00i");
}//计算机四舍五入判断为零的情况会自动带一个负号,对于double,float,类型
//判断等于0的情况需要单独列出来判断
else
printf("-%.2fi",fabs(b3));
return 0;
}