/*
* Copyright (c) 2015, 烟台大学计算机与控制工程学院
* All rights reserved.
* 文件名称: main.cpp,
* 作者:唐子健
* 完成日期:2015年10月5日
* 版本号:vc++6.0
*
* 问题描述: 用单链表存储一元多项式,并实现两个多项式的加法。
* 输入描述: 无
* 程序输出: 算法结果
*/
#include <stdio.h>
#include <malloc.h>
#define MAX 20 //多项式最多项数
typedef struct //定义存放多项式的数组类型
{
double coef; //系数
int exp; //指数
} PolyArray;
typedef struct pnode //定义单链表结点类型,保存多项式中的一项,链表构成多项式
{
double coef; //系数
int exp; //指数
struct pnode *next;
} PolyNode;
void DispPoly(PolyNode *L) //输出多项式
{
bool first=true; //first为true表示是第一项
PolyNode *p=L->next;
while (p!=NULL)
{
if (first)
first=false;
else if (p->coef>0)
printf("+");
if (p->exp==0)
数据结构实践——多项式求和
最新推荐文章于 2023-04-11 13:22:11 发布