国产成人AV一区二区三区在线_国产成人精品无码免费看_国产成人无码无卡在线观看_国产精品成人A区在线观看_国产日韩精品欧美一区_国产亚洲精品自在久久蜜TV_久草热久草热线频97精品_久久久噜噜噜久久中文福利_久久婷婷五月综合色国产免费观看_日日狠狠久久偷偷色综合0,九一桃色在线观看,久久97精品久久久久久久不卡,国产成人精品亚洲精品

用c語言寫出復(fù)數(shù)的抽象數(shù)據(jù)類型,,至少完成創(chuàng)建一個復(fù)數(shù),復(fù)數(shù)加減,,虛部等五,求一個復(fù)數(shù)的實部個操作

訪客2023-11-11 15:24:1910

依據(jù)抽象數(shù)據(jù)類型的定義#include<stdio.h>typedef struct{float r;float v;}complex;complex Initcomplex(float a,float b){complex x;x.r=a;x.v=b;return x;}void printc(complex x){printf("%.2f+&.2fi",x.r,x.v);}complex addcomplex(complex x,complex y){complex result;result.r=x.r-y.r;result.v=x.v+y.r;return result;}void main(){complex x,y;x=Initcomplex(5,2);printc(x);y=Initcomplex(5,2); printc(x);}寫到這不會

只要加減的話,,參考:

#include<stdio.h>typedef struct{float r;float v;} complex;complex Initcomplex(float a,float b){complex x;x.r=a;x.v=b;return x;}void printc(complex x){if (x.v>=0)printf("%.2f+%.2fi",x.r,x.v);elseprintf("%.2f%.2fi",x.r,x.v);}complex Addcomplex(complex x,complex y){complex result;result.r=x.r+y.r;result.v=x.v+y.v;return result;}complex Minuscomplex(complex x,complex y){complex result;result.r=x.r-y.r;result.v=x.v-y.v;return result;}int main(){complex x,y;x=Initcomplex(1,2);printc(x);y=Initcomplex(3,4);printc(y);complex z;z=Addcomplex(x,y);printc(z);z=Minuscomplex(x,y);printc(z);return 0;}

文章評論