Problem4009--复数类(运算符重载)

4009: 复数类(运算符重载)

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 2  Solved: 2
[Submit] [Status] [Web Board] [Creator:]

Description

定义一个复数类Complex,重载运算符"*","<<",">>",使之能够用于复数的乘法、输入、输出。复数乘法公式(a+bi)(c+di)=(ac-bd)+(bc+ad)i.主函数定义如下:
int main()
{Complex c1,c2,c3;
 cin>>c1>>c2;
 c3=c1*c2;
    cout<<c3;
 
 return 0;}

Input

每行二个整数,表示复数的实部和虚部。输入二个复数,必须用cin>>c1>>c2;

Output

输出一个复数,输出时不要换行,必须用cout<<c3;

Sample Input Copy

2 3 
4 5

Sample Output Copy

-7+22i

Source/Category