早教吧 育儿知识 作业答案 考试题库 百科 知识分享

利用结构变量求解两个复数之积(3+4i)*(5+6i)

题目详情
利用结构变量求解两个复数之积(3+4i)*(5+6i)
▼优质解答
答案和解析
参考:TC下
#include
struct mul
{
int real;
int image;
}f1,f2;
void main()
{
int a,b;
printf("input real and image:\n");
scanf("%d%d",&f1.real,&f1.image:\n");
printf("input real and image);
scanf("%d%d",&f2.real,&f2.image);
a=f1.real*f2.real-f1.image*f2.image;
b=f1.real*f2.image+f2.real*f1.image;
if(b>0)
printf("%d+%di",a,b);
else
printf("%d%di",a,b);
getchar();
}
DEV C++下:
#include
using namespace std;
struct mul
{
int real;
int image;
}f1,f2;
int main()
{
int a,b;
coutf1.image;
coutf2.image;
a=f1.real*f2.real-f1.image*f2.image;
b=f1.real*f2.image+f2.real*f1.image;
if(b>0)
cout
看了 利用结构变量求解两个复数之积...的网友还看了以下: