-
2020-04-14 17:34:01
若两个复数分别为:c
1
=x
1
+y
1
i和c
2
=x
2
+y
2
i,则它们的乘积为 c
1
×c
2
=(x
1
x
2
−y
1
y
2
)+(x
1
y
2
+x
2
y
1
)i。本题要求实现一个函数计算两个复数之积。
函数接口定义:
double result_real, result_imag;
void complex_prod( double x1, double y1, double x2, double y2 );其中用户传入的参.数为两个复数x1+y1i和x2+y2i;函数complex_prod应将计算结果的实部存放在全局变量result_real中、虚部存放在全局变量result_imag中。
裁判测.试程序样例:
#include<stdio.h>double result_real, result_imag;
void complex_prod( double x1, double y1, double x2, double y2 );int main(void)
{
double imag1, imag2, real1, real2;scanf("%lf %lf", &real1, &imag1); scanf("%lf %lf", &real2, &imag2); complex_prod(real1, imag1, real2, imag2); printf("product of complex is (%f)+(%f)i\n", result_real, result_imag); return 0;
}
/* 你的代码将被嵌在这里 */
输入样例:
1 2
-2 -3输出.样例:
product of complex is (4.000000)+(-7.000000)ivoid complex_prod( double x1, double y1, double x2, double y2 ){ result_real=x1*x2-y1*y2; result_imag=x1*y2+x2*y1; }
更多相关内容 -
PTA使用函数计算两个复数之积
2021-11-28 12:55:196-7 使用函数计算两个复数之积 (15 分) 若两个复数分别为:c1=x1+y1i和c2=x2+y2i,则它们的乘积为 c1×c2=(x1x2−y1y2)+(x1y2+x2y1)i。 本题要求实现一个函数计算两个复数之积。 ...6-7 使用函数计算两个复数之积 (15 分)
若两个复数分别为:c1=x1+y1i和c2=x2+y2i,则它们的乘积为 c1×c2=(x1x2−y1y2)+(x1y2+x2y1)i。
本题要求实现一个函数计算两个复数之积。
函数接口定义:
double result_real, result_imag;
void complex_prod( double x1, double y1, double x2, double y2 );
其中用户传入的参数为两个复数x1+y1i和x2+y2i;函数complex_prod应将计算结果的实部存放在全局变量result_real中、虚部存放在全局变量result_imag中。
裁判测试程序样例:
#include<stdio.h>double result_real, result_imag;
void complex_prod( double x1, double y1, double x2, double y2 );int main(void)
{
double imag1, imag2, real1, real2;scanf("%lf %lf", &real1, &imag1); scanf("%lf %lf", &real2, &imag2); complex_prod(real1, imag1, real2, imag2); printf("product of complex is (%f)+(%f)i\n", result_real, result_imag); return 0;
}
/* 你的代码将被嵌在这里 */
输入样例:
1 2
-2 -3
结尾无空行
输出样例:
product of complex is (4.000000)+(-7.000000)i
结尾无空行
-
[PTA]实验5-1 使用函数计算两个复数之积
2021-05-23 15:06:14[PTA]实验5-1 使用函数计算两个复数之积 若两个复数分别为:c₁ = x₁ + y₁i 和 c₂ = x₂ + y₂i ,则它们的乘积为:c₁ x c₂ = (x₁x₂ - y₁y₂) + (x₁y₂ + x₂y₁)i。 本题要求实现一个函数计算两个复数之积...若两个复数分别为:c₁ = x₁ + y₁i 和 c₂ = x₂ + y₂i ,则它们的乘积为:c₁ x c₂ = (x₁x₂ - y₁y₂) + (x₁y₂ + x₂y₁)i。
本题要求实现一个函数计算两个复数之积。函数接口定义:
double result_real, result_imag; void complex_prod( double x1, double y1, double x2, double y2 );
其中用户传入的参数为两个复数x₁+y₁i和x₂ + y₂i ;函数complex_prod应将计算结果的实部存放在全局变量result_real中、虚部存放在全局变量result_imag中。
裁判测试程序样例:
#include<stdio.h> double result_real, result_imag; void complex_prod( double x1, double y1, double x2, double y2 ); int main(void) { double imag1, imag2, real1, real2; scanf("%lf %lf", &real1, &imag1); scanf("%lf %lf", &real2, &imag2); complex_prod(real1, imag1, real2, imag2); printf("product of complex is (%f)+(%f)i\n", result_real, result_imag); return 0; } /* 你的代码将被嵌在这里 */
输入样例:
1 2
-2 -3
输出样例:
product of complex is (4.000000)+(-7.000000)i
- 提交结果:
- 源码:
#include<stdio.h> double result_real, result_imag; void complex_prod(double x1, double y1, double x2, double y2); int main(void) { double imag1, imag2, real1, real2; scanf("%lf %lf", &real1, &imag1); scanf("%lf %lf", &real2, &imag2); complex_prod(real1, imag1, real2, imag2); printf("product of complex is (%f)+(%f)i\n", result_real, result_imag); return 0; } /* 你的代码将被嵌在这里 */ void complex_prod(double x1, double y1, double x2, double y2) { result_real = x1 * x2 - y1 * y2; result_imag = x1 * y2 + x2 * y1; }
-
PTA:计算两个复数之积(C语言)
2020-04-20 20:28:40本题要求实现一个计算复数之积的简单函数。 函数接口定义: struct complex multiply(struct complex x, struct complex y); 其中struct complex是复数结构体,其定义如下: struct complex{ int real; int imag; };...本题要求实现一个计算复数之积的简单函数。
函数接口定义:
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 + 38istruct complex multiply(struct complex x, struct complex y) { struct complex resulst; resulst.real = x.real*y.real - x.imag*y.imag; resulst.imag = x.real*y.imag + x.imag*y.real; return resulst; }
-
PTA C 6-1 计算两个复数之积
2022-05-21 19:18:05本题要求实现一个计算复数之积的简单函数。 函数接口定义: struct complex multiply(struct complex x, struct complex y); 其中struct complex是复数结构体,其定义如下: struct complex{ int real; int imag;... -
浙大 | PTA 习题9-2 计算两个复数之积 (15分)
2020-05-04 08:59:30本题要求实现一个计算复数之积的简单函数。 函数接口定义: struct complex multiply(struct complex x, struct complex y); 其中struct complex是复数结构体,其定义如下: struct complex{ int real; int imag;... -
浙江大学 PTA 习题9-2 计算两个复数之积 (15 分)
2019-04-01 14:47:17本题要求实现一个计算复数之积的简单函数。 函数接口定义: struct complex multiply(struct complex x, struct complex y); 其中struct complex是复数结构体,其定义如下: struct complex{ int real; int imag;... -
PTA 6-6 使用函数计算两个复数之积
2022-01-05 12:52:25本题要求实现一个函数计算两个复数之积。 函数接口定义: double result_real, result_imag; void complex_prod( double x1, double y1, double x2, double y2 ); 其中用户传入的参数为两个复数x1+y1i和x2+y2i;... -
PTA:6-7 使用函数计算两个复数之积
2021-12-21 09:00:41void complex_prod( double x1, double y1, double x2, double y2 ) { result_real=x1*x2-y1*y2; result_imag=x1*y2+x2*y1; } -
使用函数计算两个复数之积
2022-03-19 16:19:38本题要求实现一个函数计算两个复数之积。 函数接口定义: double result_real, result_imag; void complex_prod( double x1, double y1, double x2, double y2 ); 其中用户传入的参数为两个复数x1+y1i和x2+y2i... -
浙江大学PTA C语言-实验9 结构程序设计 6-1 计算两个复数之积
2020-12-24 19:46:536-1 计算两个复数之积 (15分) 本题要求实现一个计算复数之积的简单函数。 函数接口定义: struct complex multiply(struct complex x, struct complex y); 其中struct complex是复数结构体,其定义如下: struct ... -
【PTA】6-1 计算两个复数之积 (10 分)
2021-05-11 20:11:31本题要求实现一个计算复数之积的简单函数。 函数接口定义: struct complex multiply(struct complex x, struct complex y); 其中struct complex是复数结构体,其定义如下: struct complex{ int real; int imag;... -
[PTA]习题9-2 计算两个复数之积
2021-05-21 19:37:28[PTA]习题9-2 计算两个复数之积 本题要求实现一个计算复数之积的简单函数。 函数接口定义: struct complex multiply(struct complex x, struct complex y); 其中struct complex是复数结构体,其定义如下: struct ... -
[PTA]实验9-4 计算两个复数之积
2021-05-26 06:41:10本题要求实现一个计算复数之积的简单函数。 函数接口定义: struct complex multiply(struct complex x, struct complex y); 其中struct complex是复数结构体,其定义如下: struct complex{ int real; int imag;... -
《程序设计基础》 第五章 函数 6-7 使用函数计算两个复数之积 (10 分)
2021-11-05 09:32:59本题要求实现一个函数计算两个复数之积。 函数接口定义: double result_real, result_imag; void complex_prod( double x1, double y1, double x2, double y2 ); 其中用户传入的参数为两个复数x1+y1i和x2+y2i;... -
习题9-2 计算两个复数之积 (15 分)
2021-07-13 20:16:41浙大版《C语言程序设计(第3版)》题目集习题9-2 计算两个复数之积 (15 分)二、题解c代码 习题9-2 计算两个复数之积 (15 分) 本题要求实现一个计算复数之积的简单函数。 函数接口定义: struct complex multiply... -
PTA(浙大版《C语言程序设计(第3版)》题目集)习题9-2 计算两个复数之积 (15 分)
2021-08-27 08:29:08PTA(浙大版《C语言程序设计(第3版)》题目集)习题9-2 计算两个复数之积 (15 分) 本题要求实现一个计算复数之积的简单函数。 函数接口定义: struct complex multiply(struct complex x, struct complex y); 其中... -
计算两个复数之积
2017-06-21 10:05:19习题9-2 计算两个复数之积 (15分) 本题要求实现一个计算复数之积的简单函数。 函数接口定义: struct complex multiply(struct complex x, struct complex y); 其中struct complex是复数结构体,其... -
PTA《C语言程序设计实验与习题指导(第3版)》题目集 实验5-1 使用函数计算两个复数之积 (10 分)
2021-08-25 00:16:28若两个复数分别为:c1=x1+y1i和c2=x2+y2i,则它们的乘积为c1×c2=(x1x2−y1y2)+(x1y2+x2y1 函数接口定义: double result_real, result_imag; void complex_prod( double x1, ... -
6-2 使用函数计算两个复数之积 (10 分)
2019-01-02 17:37:076-2 使用函数计算两个复数之积 (10 分) #include<stdio.h> double result_real, result_imag; void complex_prod( double x1, double y1, double x2, double y2 ); int main(void) { double imag1, ... -
计算2个复数之和与之积(用一种函数返回两种值)
2022-04-10 15:28:34分别输入2个复数的实部与虚部,用函数实现计算2个复数之和与之积。 若2个复数分别为:c1=x1+(y1)i, c2=x2+(y2)i, 则: c1+c2 = (x1+x2) + (y1+y2)i c1*c2 = (x1*x2-y1*y2) + (x1*y2+x2*y1)i 输入格式: 输入在... -
PTA浙大版《C语言程序设计(第3版)》题目集习题9-2 计算两个复数之积
2021-07-13 21:10:58习题9-2 计算两个复数之积 (15 分) 本题要求实现一个计算复数之积的简单函数。 函数接口定义: struct complex multiply(struct complex x, struct complex y); 其中struct complex是复数结构体,其定义如下: ... -
PTA|《C语言程序设计(第3版)》习题9-2 计算两个复数之积 (15分)
2020-02-09 17:20:57本题要求实现一个计算复数之积的简单函数。 函数接口定义: struct complex multiply(struct complex x, struct complex y); 其中struct complex是复数结构体,其定义如下: struct complex{ int real; int imag;... -
习题9-2 计算两个复数之积(15 分)
2018-04-23 02:52:12题目来源:点击打开链接本题要求实现一个计算复数之积的简单函数。函数接口定义:struct complex multiply(struct complex x, struct complex y); 其中struct complex是复数结构体,其定义如下:struct complex{ ...