本题要求实现一个计算复数之积的简单函数。
struct complex multiply(struct complex x, struct complex y);
其中struct complex
是复数结构体,其定义如下:
struct complex{
int real;
int imag;
};
#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;
}
/* 你的代码将被嵌在这里 */
3 4 5 6
结尾无空行
(3+4i) * (5+6i) = -9 + 38i
结尾无空行
struct complex multiply(struct complex x, struct complex y) //返回了一个结构multiply
{
struct complex multiply;
multiply.real = x.real * y.real - x.imag * y.imag;
multiply.imag = x.imag * y.real + x.real * y.imag;
return multiply;
}
因篇幅问题不能全部显示,请点此查看更多更全内容
怀疑对方AI换脸可以让对方摁鼻子 真人摁下去鼻子会变形
女子野生动物园下车狼悄悄靠近 后车司机按喇叭提醒
睡前玩8分钟手机身体兴奋1小时 还可能让你“变丑”
惊蛰为啥吃梨?倒春寒来不来就看惊蛰
男子高速犯困开智能驾驶出事故 60万刚买的奔驰严重损毁