#include<stdio.h>
double result_real, result_imag;
double result_reall, result_imagg;
void complex_prodd(double x1, double y1, double x2, double y2)
{
result_reall = x1 + x2;
result_imagg = y1 + y2;
}
void complex_prod(double x1, double y1, double x2, double y2)
{
result_real = x1 * x2 - y1 * y2;
result_imag = x1 * y2 + x2 * y1;
}
int main(void)
{
double imag1, imag2, real1, real2;
scanf("%lf %lf", &real1, &imag1);
scanf("%lf %lf", &real2, &imag2);
complex_prodd(real1, imag1, real2, imag2);
complex_prod(real1, imag1, real2, imag2);
printf("addition of complex is %f+%fi\n", result_reall, result_imagg);
printf("product of complex is %f+%fi\n", result_real, result_imag);
return 0;
}
自定义函数————计算2个复数之和与之积
最新推荐文章于 2022-11-29 21:41:23 发布