包括对链表的冒泡排序,归并排序,链表的释放
#include "stdio.h"
typedef struct Elem
{
double coeff;
double exp;
}Pair;
typedef struct poly
{
Pair data;
struct poly *next;
}*pPolyList,PolyList;
//比较两个数的大小,按结果返回
int cmp(double a,double b)
{
if(a > b )
return 1;
else if(a==b)
return 0;
return -1;
}
//初始化多项式链表,按组输入,直到输入的为两个 0 0 表示链接结束
void Init_Poly( pPolyList* ha)
{
double coeff;
double exp;
pPolyList pa;
coeff=0;
exp=0;
(*ha)=(pPolyList)malloc( sizeof(struct poly) );
memset(*ha,0,sizeof(PolyList));
(*ha)->next=NULL;
while(1)
{
scanf("%lf %lf",&coeff,&exp);
if(coeff ==0.0 && exp==0.0)
break;
pa=(pPolyList)malloc(sizeof(struct poly));
(pa->data).coeff=coeff;
(pa->data).e