推荐于2018-03-11
展开全部
#include <stdio.h>
typedef struct TYPE_PLURAL
{
double realpart;
double imaginarypart;
} plural;
plural operator*(const plural &lp,const plural &rp)
{
plural rtn;
rtn.realpart = lp.realpart*rp.realpart - lp.imaginarypart*rp.imaginarypart;
rtn.imaginarypart = lp.imaginarypart*rp.realpart + lp.realpart*rp.imaginarypart;
return rtn;
}
int main(int argc, char* argv[])
{
plural plr_a={5,10};
plural plr_b={2,3};
plural plr_c = plr_a*plr_b;
}
刚刚看到零回答,抽空写了个,希望对你有用
typedef struct TYPE_PLURAL
{
double realpart;
double imaginarypart;
} plural;
plural operator*(const plural &lp,const plural &rp)
{
plural rtn;
rtn.realpart = lp.realpart*rp.realpart - lp.imaginarypart*rp.imaginarypart;
rtn.imaginarypart = lp.imaginarypart*rp.realpart + lp.realpart*rp.imaginarypart;
return rtn;
}
int main(int argc, char* argv[])
{
plural plr_a={5,10};
plural plr_b={2,3};
plural plr_c = plr_a*plr_b;
}
刚刚看到零回答,抽空写了个,希望对你有用
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询