资讯详情

C语言程序设计——结构体的运用 求复数之积。利用结构变量求解如下两组复数之积。

求复数的积累。利用结构变量解决以下两组复数的积累。

za={3,4}, zb={5,6}

za={10,20}, zb={30,40}

**输出格式要求:"(%d %di)*(%d %di)=" "(%d %di)\n" 程序运行示例如下: (3 4i)*(5 6i)=(-9 38i) (10 20i)*(30 40i)=(-500 1000i)

#include "stdio.h"  struct complx {              int real;   int im; }           ; main() {              static struct complx za={3,4};   static struct complx zb={5,6};   struct complx x,y,z;   struct complx cmult();   void cpr();   z=cmult(za,zb);   cpr(za,zb,z);   x.real = 10; x.im = 20;   y.real = 30; y.im = 40;   z=cmult(x,y);   cpr(x,y,z); }            struct complx cmult(struct complx za, struct complx zb) {                  struct complx w;       w.real = za.real*zb.real - za.im*zb.im;       w.im   = za.real*zb.im za.im*zb.real;       return w; }            void cpr(struct complx za, struct complx zb, struct complx z) {                printf("(%d %di)*(%d %di)=",za.real,za.im,zb.real,zb.im);     printf("(%d %di)\n",z.real,z.im); }            

标签: zb2188板型电阻

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

锐单商城 - 一站式电子元器件采购平台