关于matlab求导数数的C语言

C Language(40)
Data Structure(34)
//一元多项式的求导
#include&stdio.h&
#include&malloc.h&//动态申请空间的函数的头文件
typedef struct node
//定义节点类型
//多项式的系数
//多项式的指数
struct node * //结点指针域
void insert(PLOYList *head,PLOYList *input)
//查找位置插入新链节的函数,且让输入的多项式呈降序排列
PLOYList *pre,*
int signal=0;
if(pre-&next==NULL) {pre-&next=} //如果只有一个头结点,则把新结点直接连在后面
now=pre-&//如果不是只有一个头结点,则设置now指针
while(signal==0)
if(input-&expn & now-&expn)
if(now-&next==NULL)
now-&next=
now=pre-&//始终让新输入的数的指数与最后一个结点中的数的指数比较,小于则插在其后面
else if( input-&expn & now-&expn )
input-&next=
pre-&next=
}//若新结点中指数比最后一个结点即now中的指数大,则插入now之前
else//若指数相等则需合并为一个结点,若相加后指数为0则释放该结点
now-&coef=now-&coef+input-&
free(input);
if(now-&coef==0)
pre-&next=now-&
free(now);
PLOYList *creat(char ch)
//输入多项式
PLOYList *head,*
head=(PLOYList *)malloc(sizeof(PLOYList));
//创建链表头
head-&next=NULL;
scanf(&%f %d&,&x,&y);//实现用户输入的第一个项,包括其指数和系数
while(x!=0)//当用户没有输入结束标志0时可一直输入多项式的项,且输入一个创建一个结点
input=(PLOYList *)malloc(sizeof(PLOYList));
//创建新链节
input-&coef=x;
input-&expn=y;
input-&next=NULL;
insert(head,input);
//每输入一项就将其排序,是的链表中多项式呈降序排列
scanf(&%f %d&,&x,&y);
PLOYList *der(PLOYList *head)//多项式求导
PLOYList *p;
p = head -&
p -& coef = p -& coef * p -&
p -& expn = p -& expn--;
}//将多项式的每项系数和指数相乘得到新的系数,指数减一得到新的指数即完成求导
void print(PLOYList *fun)
//输出多项式,fun指要输出的多项式链表的表头
PLOYList *
int flag=0;
printing=fun-&
if(fun-&next==NULL)//若为空表,则无需输出
printf(&0\n&);
while(flag==0)
if(printing-&coef&0&&fun-&next!=printing)
printf(&+&);
if(printing-&coef==1);
else if(printing-&coef==-1)
printf(&-&);
printf(&%f&,printing-&coef);
if(printing-&expn!=0) printf(&x^%d&,printing-&expn);
else if((printing-&coef==1)||(printing-&coef==-1))
printf(&1&);
if(printing-&next==NULL)
printing=printing-&
printf(&\n&);
void main()
PLOYList *f;
printf(& 注:输入多项式格式为:系数1 指数1 系数2 指数2 …… ,并以0 0 结束:\n&);
printf(&请输入一个一元多项式:&);
f = creat('f');
printf(&这个多项式为:f(x)= &);
printf(&求导结果为:F(x)=f'(x)= &);
printf(&\n\n&);
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:71166次
积分:2325
积分:2325
排名:第12903名
原创:166篇
阅读:1294
阅读:1489
文章:11篇
阅读:5900
(1)(14)(15)(27)(16)(27)(14)(3)(1)(5)(11)(15)(10)(11)(4)(4)求导大神指导C语言题目,我是新手,
时夏MH70VL
5.4:(a)输出:2 0&&&&&&&&&(b)输出:1 16.9:(a)输出:-1&&&&&&&&(b)输出:0&&&&&&&&(c)输出:5555555.&&&&&&&&(d)输出:10 85.10://没测试过,可能有笔误#include&&stdio.h&#include&&math.h&&//可以用math.h的库吗//顺便说一下,那个求根公式貌似写错了,-b应该放在分子上的吧.&int&main(){&&&&double&a,&b,&c;&&&&printf(&issue&the&values&of&a,&b,&c(divided&by&space):&):&&&&&scanf(&%d%d%d&);&&&&if&(a&==&0)&&&&{&&&&&&&&&if&(b&==&0)&&&&&&&&&&&&printf(&the&root&is:&%d&,&c):&&&&&&&&else&&&&&&&&&&&&printf(&the&root&is:&%d&,&-c&/&b);&&&&&&&&&&goto&END;&&&&&}&&&&&double&delta&=&b&*&b&-&(4&*&a&*&c);&&&&if&(delta&&&0)//two&real&roots&&&&&&&&&&printf(&the&roots&is:&%d&and&%d&,&(-b&+&sqrt(delta))&/&2&*&a,&(-b&-&sqrt(delta))&/&2&*&a);&&&&else&if&(delta&==&0)&&&&&&&&&&printf(&the&root&is:&%d&,&(-b&+&sqrt(delta))&/&2&*&a);&&&&else&&&&&&&&printf(&there&are&no&real&roots!&);&END:;&&}额,还有.6.9的c项是我看错了吗?目测是个死循环.个人临时做的供参考,有错谢谢指正.
为您推荐:
其他类似问题
扫描下载二维码求函数的导数_高等数学吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:223,575贴子:
求函数的导数收藏
登录百度帐号推荐应用
为兴趣而生,贴吧更懂你。或用C语言如何编写函数的求导
将先用算法将 f(x)拆分成最基本的求导函数 f(x)=f1(x)+f2(x)+.然后使用最基本的函数求导公式求这种程序比较麻烦,
为您推荐:
其他类似问题
扫描下载二维码

我要回帖

更多关于 求导数 的文章

 

随机推荐