博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
复数 一级ADT实现
阅读量:4575 次
发布时间:2019-06-08

本文共 1379 字,大约阅读时间需要 4 分钟。

COMPLEX.h

1 /* 2 typedef struct 3 { 4     float RE; //实部 5     float IM; //虚部 6 }Complex; 7 */ 8 typedef struct complex * Complex; 9 10 Complex COMPLEXinit(float, float);11 float Re(Complex);12 float Im(Complex);13 Complex COMPLEXmult(Complex, Complex);

COMPLEX.c

1 #include "COMPLEX.h" 2  3 struct complex 4 { 5     float RE; //实部 6     float IM; //虚部 7 }; 8  9 Complex COMPLEXinit(float RE, float IM)10 {11     /*12     Complex t;13     t.RE=RE;14     t.IM=IM;15     return t;16     */17     18     Complex t=malloc(sizeof *t);19     t->RE=RE;20     t->IM=IM;21     return t;22 }23 float Re(Complex z)24 {25     return z->RE;26 }27 float Im(Complex z)28 {29     return z->IM;30 }31 Complex COMPLEXmult(Complex a, Complex b)32 {33     /*34     Complex t;35     t.RE=a.RE*b.RE-a.IM*b.IM;36     t.IM=a.RE*b.IM+a.IM*b.RE;37     38     //a实部乘b实部-a虚部乘b虚部39     //a实部乘b虚部+a虚部乘b实部40     return t;*/41     42     return COMPLEXinit(Re(a)*Re(b)-Im(a)*Im(b),43                        Re(a)*Im(b)+Im(a)*Re(b));44 }

main.c

1 #include 
2 #include
3 #include "COMPLEX.h" 4 5 #define PI 3.141592625 6 7 int main(void) 8 { 9 int N;10 printf("输入一个参数:");11 scanf("%d", &N);12 getchar();13 14 Complex t, x;15 printf("%dth complex roots of unity\n", N);16 for(int i=0; i

 

转载于:https://www.cnblogs.com/WALLACE-S-BOOK/p/9044875.html

你可能感兴趣的文章
为什么要配置sdk-tools/platform-toools?
查看>>
自己动手开发更好用的markdown编辑器-07(扩展语法)
查看>>
maven dependency:tree中反斜杠的含义
查看>>
队列的循环队列
查看>>
程序中的日期格式
查看>>
大众点评CAT错误总结以及解决思路
查看>>
从0开始学爬虫3之xpath的介绍和使用
查看>>
vim下正则表达式的非贪婪匹配
查看>>
一个python的计算熵(entropy)的函数
查看>>
spring源码学习——spring整体架构和设计理念
查看>>
模拟window系统的“回收站”
查看>>
报文格式【定长报文】
查看>>
RDLC报表钻取空白页问题
查看>>
多路电梯调度的思想
查看>>
jQuery-对Select的操作
查看>>
过滤器、监听器、拦截器的区别
查看>>
为什么要进行需求分析?通常对软件系统有哪些需求?
查看>>
一些模板
查看>>
jquery和dom元素相互转换
查看>>
放大的X--HDOJ-201307292012
查看>>