要会使用math函数,
还要注意到用四舍五入的方法判断是否应该输出0.00

#include <math.h>
#include<stdio.h>
int main() {
    double r1, p1, r2, p2, A, B;
    scanf("%lf %lf %lf %lf",&r1,&p1,&r2,&p2);
    r1*=r2;p1+=p2;
    A = r1 * cos(p1);
    B = r1 * sin(p1);
    if (A + 0.005 >= 0 && A < 0)
        printf("0.00");
    else
        printf("%.2f", A);
    if(B >= 0)
        printf("+%.2fi", B);
    else if (B + 0.005 >= 0 && B < 0)
        printf("+0.00i");
    else
		printf("%.2lfi", B);
    return 0;
}

相关文章:

  • 2021-07-11
  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
  • 2022-12-23
  • 2021-09-23
猜你喜欢
  • 2021-07-07
  • 2022-12-23
  • 2021-06-29
  • 2021-11-10
  • 2022-12-23
  • 2021-12-01
  • 2021-09-29
相关资源
相似解决方案