编写求两个复数之积的函数product()求复数之积
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
2016-09-30
展开全部
/*
输入样例:
3 4 5 6
输出样例:
(3+4i) * (5+6i) = -9 + 38i
*/
#include <stdio.h>
struct complex{
int real;
int imag;
};
struct complex multiply(struct complex x, struct complex y);
int main()
{
struct complex product, x, y;
scanf("%d%d%d%d", &x.real, &x.imag, &y.real, &y.imag);
product = multiply(x, y);
printf("(%d+%di) * (%d+%di) = %d + %di\n",
x.real, x.imag, y.real, y.imag, product.real, product.imag);
return 0;
}
struct complex multiply(struct complex x, struct complex y)
{
struct complex product;
product.real=x.real*y.real-x.imag*y.imag;
product.imag=x.real*y.imag+x.imag*y.real;
return product;
}
输入样例:
3 4 5 6
输出样例:
(3+4i) * (5+6i) = -9 + 38i
*/
#include <stdio.h>
struct complex{
int real;
int imag;
};
struct complex multiply(struct complex x, struct complex y);
int main()
{
struct complex product, x, y;
scanf("%d%d%d%d", &x.real, &x.imag, &y.real, &y.imag);
product = multiply(x, y);
printf("(%d+%di) * (%d+%di) = %d + %di\n",
x.real, x.imag, y.real, y.imag, product.real, product.imag);
return 0;
}
struct complex multiply(struct complex x, struct complex y)
{
struct complex product;
product.real=x.real*y.real-x.imag*y.imag;
product.imag=x.real*y.imag+x.imag*y.real;
return product;
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询