速度解答出来,程序在C++里能成功运行。再追加100积分。别在网上搜了就直接复制了,必须能在C++程序里成功运行。
已知两个复数5.6+i4.8和3.4+i1.2,求它们的和与积。描述复数运算使用下述结构模式:
答案:2 悬赏:50 手机版
解决时间 2021-05-17 14:18
- 提问者网友:锁深秋
- 2021-05-17 04:00
最佳答案
- 五星知识达人网友:旧脸谱
- 2021-05-17 04:29
已知两个复数5.6+i4.8和3.4+i1.2,求它们的和与积。描述复数运算使用下述结构模式:
struct complex
{ double re;
double im;
} 参考程序:
struct complex
{ double re,im;
}; #include <iostream.h>
void main()
{ struct complex x={5.6,4.8},y={3.4,1.2};
struct complex,struct complex z1,z2;
add (struct complex,struct comlex);
mulitiply (struct complex,struct complex);
z1=add(x,y);
z2=mulitiply(x,y);
count<<'("x.re<<"+i"<<x.im<<")+("<<y.re<<"+I"<<y.rm<<")=";
count<<'("x.re<<"+i"<<x.im<<")<<endl;
count<<'("x.re<<"+i"<<x.im<<")*("<<y.re<<"+I"<<y.rm<<")=";
count<<'("x.re<<"+i"<<x.im<<")<<endl;
} struct complex add(struct complex x,struct complex y)
{ struct complex z;
z.re=x.re+y.re;
z.rm=x.rm+y.rm;
retrun z;
} struct complex mulitiply(struct complex x, struct complex y)
{ struct complex z;
z.re=x.re*y.re+x.im*y.im:
z.rm=x.re*y.im+x.im*y.re;
return z;
struct complex
{ double re;
double im;
} 参考程序:
struct complex
{ double re,im;
}; #include <iostream.h>
void main()
{ struct complex x={5.6,4.8},y={3.4,1.2};
struct complex,struct complex z1,z2;
add (struct complex,struct comlex);
mulitiply (struct complex,struct complex);
z1=add(x,y);
z2=mulitiply(x,y);
count<<'("x.re<<"+i"<<x.im<<")+("<<y.re<<"+I"<<y.rm<<")=";
count<<'("x.re<<"+i"<<x.im<<")<<endl;
count<<'("x.re<<"+i"<<x.im<<")*("<<y.re<<"+I"<<y.rm<<")=";
count<<'("x.re<<"+i"<<x.im<<")<<endl;
} struct complex add(struct complex x,struct complex y)
{ struct complex z;
z.re=x.re+y.re;
z.rm=x.rm+y.rm;
retrun z;
} struct complex mulitiply(struct complex x, struct complex y)
{ struct complex z;
z.re=x.re*y.re+x.im*y.im:
z.rm=x.re*y.im+x.im*y.re;
return z;
全部回答
- 1楼网友:妄饮晩冬酒
- 2021-05-17 05:30
,求它们的和与积
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯