C语言入门编程题
#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;
}
刚刚看到零回答,抽空写了个,希望对你有用
温馨提示:答案为网友推荐,仅供参考