vc++中没有<complex.h>头文件,不知道怎么调用?
/*Program2.17Workingwithcomplexnumbers*/#include<complex.h>#include<stdio.h>intmain(v...
/* Program 2.17 Working with complex numbers */
#include <complex.h>
#include <stdio.h>
int main(void)
{
double complex cx = 1.0 + 3.0*I;
double complex cy = 1.0 - 4.0*I;
printf("Working with complex numbers:");
printf("\nStarting values: cx = %.2f%+.2fi cy = %.2f%+.2fi",
creal(cx), cimag(cx), creal(cy), cimag(cy));
double complex sum = cx+cy;
printf("\n\nThe sum cx + cy = %.2f%+.2fi",
creal(sum),cimag(sum));
double complex difference = cx-cy;
printf("\n\nThe difference cx - cy = %.2f%+.2fi", creal(difference),cimag(difference));
double complex product = cx*cy;
printf("\n\nThe product cx * cy = %.2f%+.2fi",
creal(product),cimag(product));
double complex quotient = cx/cy;
printf("\n\nThe quotient cx / cy = %.2f%+.2fi",
creal(quotient),cimag(quotient));
double complex conjugate = conj(cx);
printf("\n\nThe conjugate of cx = %.2f%+.2fi",
creal(conjugate) ,cimag(conjugate));
return 0;
} 展开
#include <complex.h>
#include <stdio.h>
int main(void)
{
double complex cx = 1.0 + 3.0*I;
double complex cy = 1.0 - 4.0*I;
printf("Working with complex numbers:");
printf("\nStarting values: cx = %.2f%+.2fi cy = %.2f%+.2fi",
creal(cx), cimag(cx), creal(cy), cimag(cy));
double complex sum = cx+cy;
printf("\n\nThe sum cx + cy = %.2f%+.2fi",
creal(sum),cimag(sum));
double complex difference = cx-cy;
printf("\n\nThe difference cx - cy = %.2f%+.2fi", creal(difference),cimag(difference));
double complex product = cx*cy;
printf("\n\nThe product cx * cy = %.2f%+.2fi",
creal(product),cimag(product));
double complex quotient = cx/cy;
printf("\n\nThe quotient cx / cy = %.2f%+.2fi",
creal(quotient),cimag(quotient));
double complex conjugate = conj(cx);
printf("\n\nThe conjugate of cx = %.2f%+.2fi",
creal(conjugate) ,cimag(conjugate));
return 0;
} 展开
2个回答
展开全部
#include <stdio.h>
#include<complex>
using namespace std;
将前面的两个include替换成上面代码。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
Storm代理
2023-08-29 广告
2023-08-29 广告
"StormProxies是全球大数据IP资源服务商,其住宅代理网络由真实的家庭住宅IP组成,可为企业或个人提供满足各种场景的代理产品。点击免费测试(注册即送1G流量)StormProxies有哪些优势?1、IP+端口提取形式,不限带宽,I...
点击进入详情页
本回答由Storm代理提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询