大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
#include#includetypedef struct {
float realpart;//实部
float imagpart;//虚部
} Complex; //定义复数抽象类型
void assign(Complex *A, float real, float imag);//赋值
void add(Complex *S, Complex A, Complex B); //+
void minus(Complex *A, float real, float imag); //-
void multiply(Complex *M, Complex A, Complex B); //*
void divide(Complex *D, Complex A, Complex B); // 除
void assign(Complex *A, float real, float imag) {
A->imagpart = imag;
A->realpart = real;
}
void add(Complex *S, Complex A, Complex B) {
S->realpart = A.realpart + B.realpart;
S->imagpart = A.imagpart + B.imagpart;
}
void multiply(Complex *M, Complex A, Complex B) {
M->realpart = A.realpart * B.realpart - A.imagpart * B.imagpart;
M->imagpart = A.imagpart * B.realpart + A.realpart * B.imagpart;
}
void divide(Complex *D, Complex A, Complex B) {
printf("pow(B.realpart, 2)=%f\n",(A.realpart * B.realpart + A.imagpart * B.imagpart) / (pow(B.realpart, 2) + pow(B.imagpart, 2)));
D->realpart = (A.realpart * B.realpart + A.imagpart * B.imagpart) / (pow(B.realpart, 2) + pow(B.imagpart, 2));
D->imagpart = (A.imagpart * B.realpart - A.realpart * B.imagpart) / (pow(B.realpart, 2) + pow(B.imagpart, 2));
}
int main(void) {
Complex A, B, C, D, E;
assign(&A, 8.0, 6.0);
assign(&B, 4.0, 3.0);
add(&C, A, B);
multiply(&D, A, B);
divide(&E, D, C);
printf("D的实部为:%.2f\n", D.realpart);
printf("D的虚部为%.2f\n", D.imagpart);
printf("C的实部为%.2f\n", C.realpart);
printf("C的虚部为%.2f\n", C.imagpart);
printf("E的实部为:%.2f\n", E.realpart);
printf("E的虚部为:%.2f\n", E.imagpart);
return 0;
}
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧
专业从事成都做网站、成都网站建设、成都外贸网站建设,高端网站制作设计,微信小程序定制开发,网站推广的成都做网站的公司。优秀技术团队竭力真诚服务,采用H5技术+CSS3前端渲染技术,响应式网站建设,让网站在手机、平板、PC、微信下都能呈现。建站过程建立专项小组,与您实时在线互动,随时提供解决方案,畅聊想法和感受。