记录一下问题。
v1(13分)
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
#define ll long long
int main(){
double r1,p1,r2,p2;
cin>>r1>>p1>>r2>>p2;
double a1=r1*cos(p1);
double b1=r1*sin(p1);
double a2=r2*cos(p2);
double b2=r2*sin(p2);
double c1=a1*a2-b1*b2;
double c2=a1*b2+b1*a2;
if(c2<0){
printf("%.2lf-%.2lfi",c1,fabs(c2));
}else{
printf("%.2lf+%.2lfi",c1,c2);
}
return 0;
}
修正,
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
#define ll long long
int main(){
double r1,p1,r2,p2;
cin>>r1>>p1>>r2>>p2;
double a1=r1*cos(p1);
double b1=r1*sin(p1);
double a2=r2*cos(p2);
double b2=r2*sin(p2);
double c1=a1*a2-b1*b2;
double c2=a1*b2+b1*a2;
if(fabs(c1)<0.01) c1=0;
if(fabs(c2)<0.01) c2=0;
if(c2<0){
printf("%.2lf-%.2lfi",c1,fabs(c2));
}else{
printf("%.2lf+%.2lfi",c1,fabs(c2));
}
return 0;
}
标签:p2,1051,p1,r1,r2,double,复数,b2,乘法
From: https://www.cnblogs.com/chengyiyuki/p/18143752