果
#include <stdio.h>
struct complex
{
int re;
int im;
};
void add(struct complex a, struct complex b, struct complex *c)
{
c->re=a.re+b.re;
c->im=a.im+b.im;
}
void minus(struct complex a, struct complex b, struct complex *c)
{
c->re=a.re-b.re;
c->im=a.im-b.im;
}
int main()
{
struct complex x,y,s,p;
scanf("%d%d",&x.re,&x.im);
scanf("%d%d",&y.re,&y.im);
add(x,y,&s);
printf(" sum=%5d+%5di\n",s.re,s.im);
minus(x,y,&p);
printf(" product=%5d+%5di\n",p.re,p.im);
return 0;
}
struct complex
{
int re;
int im;
};
void add(struct complex a, struct complex b, struct complex *c)
{
c->re=a.re+b.re;
c->im=a.im+b.im;
}
void minus(struct complex a, struct complex b, struct complex *c)
{
c->re=a.re-b.re;
c->im=a.im-b.im;
}
int main()
{
struct complex x,y,s,p;
scanf("%d%d",&x.re,&x.im);
scanf("%d%d",&y.re,&y.im);
add(x,y,&s);
printf(" sum=%5d+%5di\n",s.re,s.im);
minus(x,y,&p);
printf(" product=%5d+%5di\n",p.re,p.im);
return 0;
}
温馨提示:答案为网友推荐,仅供参考