7-2 一元多项式的乘法与加法运算(20 分)

这是一个实现一元多项式加法和乘法运算的C语言程序。程序通过结构体存储多项式项,使用链表数据结构进行操作。`read()`函数读取多项式,`add()`函数实现加法,`mul()`函数实现乘法,最后`print()`函数打印结果。
摘要由CSDN通过智能技术生成

#include<stdio.h>
#include<stdlib.h>
typedef struct xiang *zz;
struct xiang{
  int xi;
  int zhi;
  zz next;
};
zz read()
{
  int count;
  zz head=NULL,tail=NULL;
  scanf("%d",&count);
  while(count-->0){
    zz newx=(zz)malloc(sizeof(struct xiang));
    scanf("%d%d",&(newx->xi),&(newx->zhi));
    newx->next=NULL;
    if(!head){
      head=newx;
      tail=newx;
    }
    else{
      tail->next=newx;
      tail=tail->next;
    }
  }
  return head;
}
zz add(zz dxs1 ,zz dxs2){
    zz sum=NULL,tail=NULL,newn;
    while(dxs1&&dxs2){
        newn=(zz)malloc(sizeof(struct xiang));
        if(dxs1->zhi>dxs2->zhi){
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值