文章
34
粉丝
89
获赞
2
访问
18.5k
#include<bits/stdc++.h> using namespace std; struct Complex{ double real; double image; Complex operator + (const Complex &c) const{ Complex cpx; cpx.real = this->real + c.real; cpx.image = this->image + c.image; return cpx; } Complex operator * (const Complex &c) const{ Complex cpx; cpx.real = (this->real * c.real) - (this -> image * c.image); cpx.image = (this->real * c.image) + (this -> image * c.real); return cpx; } }; int main(){ double a,b,c,d; char ch; cin >> a >> b >> c >> d >> ch; Complex c1 = {a,b}; Complex c2 = {c,d}; if(ch == '*'){ Complex c3 = c1 * c2; printf("%.1lf %.1lf",c3.real,c3.image); }else{ Complex c3 = c1 + c2; printf("%.1lf %.1lf",c3.real,c3.image); } return 0; }
登录后发布评论
暂无评论,来抢沙发