c语言 复数 运算
怎么让C语言实现e的复次幂运算?比如经典的e^(pi*i)=-1还有e^(i)=0.5403+0.8415i?还有怎么求(1+i)^0.3这样的函数?编程需要用到这些计算...
怎么让C语言实现e的复次幂运算?
比如经典的e^(pi*i)=-1
还有e^(i)=0.5403 + 0.8415i ?
还有怎么求(1+i)^0.3这样的函数?编程需要用到这些计算 展开
比如经典的e^(pi*i)=-1
还有e^(i)=0.5403 + 0.8415i ?
还有怎么求(1+i)^0.3这样的函数?编程需要用到这些计算 展开
2个回答
展开全部
这个是一个列子,可以参考下
struct complex{
float rmz; //实部
float lmz;//虚部
};
//产生一个复数.
complex getAComplex(float a,float b){
complex Node=new complex();
Node.rmz=a;
Node.lmz=b;
return Node;}
//两个复数求和
complex addComplex(complex complex1,complex complex2)
{
complex Node=new complex();
Node.rmz=complex1.rmz+complex2.rmz;
Node.lmz=complex1.lmz+complex2.lmz;
return Node;
}
//求两个复数的差
complex subComplex(complex complex1,complex complex2)
{
complex Node=new complex();
Node.rmz=complex1.rmz-complex2.rmz;
Node.lmz=complex1.lmz-complex2.lmz;
return Node;
}
//求两个复数的积
complex productComplex(complex complex1,complex complex2)
{
complex Node=new complex();
Node.rmz=complex1.rmz*complex2.rmz-complex1.lmz*complex2.lmz;
Node.lmz=complex1.lmz*complex2.rmz+complex2.lmz*complex2.rmz;
return Node;
}
//求实部
float getComplexRmz(complex complex1)
{
return complex1.rmz;
}
//求虚部
float getComplexLmz(complex complex1)
{
return complex1.lmz;
}
struct complex{
float rmz; //实部
float lmz;//虚部
};
//产生一个复数.
complex getAComplex(float a,float b){
complex Node=new complex();
Node.rmz=a;
Node.lmz=b;
return Node;}
//两个复数求和
complex addComplex(complex complex1,complex complex2)
{
complex Node=new complex();
Node.rmz=complex1.rmz+complex2.rmz;
Node.lmz=complex1.lmz+complex2.lmz;
return Node;
}
//求两个复数的差
complex subComplex(complex complex1,complex complex2)
{
complex Node=new complex();
Node.rmz=complex1.rmz-complex2.rmz;
Node.lmz=complex1.lmz-complex2.lmz;
return Node;
}
//求两个复数的积
complex productComplex(complex complex1,complex complex2)
{
complex Node=new complex();
Node.rmz=complex1.rmz*complex2.rmz-complex1.lmz*complex2.lmz;
Node.lmz=complex1.lmz*complex2.rmz+complex2.lmz*complex2.rmz;
return Node;
}
//求实部
float getComplexRmz(complex complex1)
{
return complex1.rmz;
}
//求虚部
float getComplexLmz(complex complex1)
{
return complex1.lmz;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询