大佬们这个怎么写啊
定义 Complex 类型(复数)。对于 c1、c2(Complex c1, c2;),支持以下运算:
cin>>c1>>c2;
cout<<c1<<c2<<endl;
c1+c2;
c1-c2;
c1*c2;
c1/c2;
+c1;
-c2;
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
// 在这里输入你的代码
int main()
{
Complex c1, c2;
Complex c3, c4;
cin >> c1 >> c2;
cout << "c1 = " << c1 << endl;
cout << "c2 = " << c2 << endl;
cout << c1 << " + " << c2 << " = " << c1 + c2 << endl;
cout << c1 << " - " << c2 << " = " << c1 - c2 << endl;
cout << c1 << " * " << c2 << " = " << c1 * c2 << endl;
cout << c1 << " / " << c2 << " = " << c1 / c2 << endl;
cout << "+" << c1 << " = " << +c1 << endl;
cout << "-" << c1 << " = " << -c1 << endl;
return 0;
}
输入
2 个复数。
输出
2个复数。以及他们的:
和
差
积
商
正值
负值
样例输入 Copy
2 -3 4 5
样例输出 Copy
c1 = (2-3i)
c2 = (4+5i)
(2-3i) + (4+5i) = (6+2i)
(2-3i) - (4+5i) = (-2-8i)
(2-3i) * (4+5i) = (23-2i)
(2-3i) / (4+5i) = (-0.170732-0.536585i)
+(2-3i) = (2-3i)
-(2-3i) = (-2+3i)
页:
[1]