1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-16 15:44:39 +00:00
202401-programming-assignments/【实践课外】15.结构体1/6-6 复数相乘运算.md

52 lines
686 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 6-6 复数相乘运算
本题要求实现一个函数,可计算两个复数相乘的积。
### 函数接口定义:
```c++
PLEX multi(PLEX a,PLEX b);
```
其中 `a` 和 `b` 都是复数返回值也为复数值为a*b的值。
### 裁判测试程序样例:
```c++
#include <stdio.h>
typedef struct
{
float re,im;
}PLEX;
PLEX multi(PLEX a,PLEX b);
int main()
{
PLEX x,y,z;
scanf("%f%f",&x.re,&x.im);
scanf("%f%f",&y.re,&y.im);
z=multi(x,y);
if(z.im>=0)
printf("%.2f+%.2fi",z.re,z.im);
else
printf("%.2f%.2fi",z.re,z.im);
return 0;
}
/* 请在这里填写答案 */
```
### 输入样例:
```in
1 2
3 4
```
### 输出样例:
```out
-5.00+10.00i
```