linux下c语言编程多项式求和,c语言中多项式求和的代码?

C语言是一门通用计算机编程语言,广泛应用于底层开发。C语言的设计目标是提供一种能以简易的方式编译、处理低级存储器、产生少量的机器码以及不需要任何运行环境支持便能运行的编程语言。c语言中多项式求和的代码如下:

#include

#include

#include

struct dxs

{

float num; //系数

int power; //指数

struct dxs *prior;

struct dxs *next;

};

struct dxs *creat() //输入

{

struct dxs *head,*p1,*p2;

int i,n;

head=(struct dxs*)malloc(sizeof(struct dxs));

head->prior=head->next=NULL;

p1=head;

if(!head)

{

printf("内存分配失败!\a");

exit(0);

}

printf("\n输入多项式项数:");

scanf("%d",&n);

for(i=0;i

{

p2=(struct dxs*)malloc(sizeof(struct dxs));

if(!p1)

{

printf("内存分配失败!\a");

exit(1);

}

printf("输入第%d项系数和指数(以空格分开):",i+1);

scanf("%f%d",&p2->num,&p2->power);

p1->next=p2;

p2->prior=p1;

p1=p2;

}

p2->next=NULL;

printf("\n已创建该多项式\n\n");

return head;

}

void insert(struct dxs *head) //插入

{

char ch;

struct dxs *newItem,*temp,*p;

temp=head;

p=head->next;

newItem=(struct dxs*)malloc(sizeof(struct dxs));

system("cls");

if(!newItem)

{

printf("内存分配失败!\a");

exit(2)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值