复数乘法* 下面的程序输入两个复数(实部、虚部),相乘后输出乘积。请在空白处填写适当内容完成该程序。 #include <stdio.h> typedef struct { double rp, ip; } COMPLEX; void Input(COMPLEX *p); void Output(const COMPLEX *p); COMPLEX Multiply(COMPLEX *p, COMPLEX *q); int main() { COMPLEX a, b, c; Input(&a); Input(&b); c = ; Output(&c); return 0; } void Input(COMPLEX *p) { scanf("%lg %lg", ); } void Output(const COMPLEX *p) { printf("%g %g", ); } COMPLEX Multiply(COMPLEX *p, COMPLEX *q) { COMPLEX r; r.rp = ; r.ip = ; return r; }
时间: 2024-04-03 07:32:11 浏览: 132
# include <stdio.h>
typedef struct {
double rp, ip;
} COMPLEX;
void Input(COMPLEX *p);
void Output(const COMPLEX *p);
COMPLEX Multiply(COMPLEX *p, COMPLEX *q);
int main() {
COMPLEX a, b, c;
Input(&a);
Input(&b);
c = Multiply(&a, &b);
Output(&c);
return 0;
}
void Input(COMPLEX *p) {
scanf("%lg %lg", &p->rp, &p->ip);
}
void Output(const COMPLEX *p) {
printf("%g %g", p->rp, p->ip);
}
COMPLEX Multiply(COMPLEX *p, COMPLEX *q) {
COMPLEX r;
r.rp = p->rp * q->rp - p->ip * q->ip;
r.ip = p->rp * q->ip + p->ip * q->rp;
return r;
}
阅读全文