c语言,求复数之积。利用结构变量求解如下两组复数之积。 za={3,4}, zb={5,6} za={10,20}, zb={30,40} **输出格式要求:"(%d+%di)*(%d+%di)=" "(%d+%di)\n" 程序运行示例如下: (3+4i)*(5+6i)=(-9+38i) (10+20i)*(30+40i)=(-500+1000i)
时间: 2024-02-28 21:57:51 浏览: 61
C语言程序设计-计算并输出给定整数的所有因子之积(包括自身);规定这个整数的值不大于50;
5星 · 资源好评率100%
以下是求解两组复数之积的 C 语言代码:
```c
#include <stdio.h>
struct Complex {
int real;
int imag;
};
int main() {
struct Complex za1 = {3, 4};
struct Complex zb1 = {5, 6};
struct Complex za2 = {10, 20};
struct Complex zb2 = {30, 40};
// 计算第一组复数之积
int real1 = za1.real * zb1.real - za1.imag * zb1.imag;
int imag1 = za1.real * zb1.imag + za1.imag * zb1.real;
printf("(%d+%di)*(%d+%di)=(%d+%di)\n", za1.real, za1.imag, zb1.real, zb1.imag, real1, imag1);
// 计算第二组复数之积
int real2 = za2.real * zb2.real - za2.imag * zb2.imag;
int imag2 = za2.real * zb2.imag + za2.imag * zb2.real;
printf("(%d+%di)*(%d+%di)=(%d+%di)\n", za2.real, za2.imag, zb2.real, zb2.imag, real2, imag2);
return 0;
}
```
输出结果为:
```
(3+4i)*(5+6i)=(-9+38i)
(10+20i)*(30+40i)=(-500+1000i)
```
阅读全文