/* c1.h (程序名) */
#include<string.h>
#include<ctype.h>
#include<malloc.h> /* malloc()等 */
#include<limits.h> /* INT_MAX 等 */
#include<stdio.h> /* EOF(=^Z 或 F6),NULL */
#include<stdlib.h> /* atoi() */
#include<io.h> /* eof() */
#include<math.h> /* floor(),ceil(),abs() */
#include<process.h> /* exit() */
/* 函数结果状态代码 */
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
/* #define OVERFLOW -2 因为在 math.h 中已定义 OVERFLOW 的值为 3,故去掉此行 */
typedef int Status; /* Status 是函数的类型,其值是函数结果状态代码,如 OK 等 */
typedef int Boolean; /* Boolean 是布尔类型,其值是 TRUE 或 FALSE */
�
/* c2-6.h 抽象数据类型 Polynomial 的实现 */
typedef struct /* 项的表示,多项式的项作为 LinkList 的数据元素 */
{
float coef; /* 系数 */
int expn; /* 指数 */
}term,ElemType;
/* 两个类型名:term 用于本 ADT,ElemType 为 LinkList 的数据对象名 */
/* c2-5.h 带头结点的线性链表类型 */
typedef struct LNode /* 结点类型 */
{
ElemType data;
struct LNode *next;
}LNode,*Link,*Position;
typedef struct LinkList /* 链表类型 */
{
Link head,tail; /* 分别指向线性链表中的头结点和最后一个结点 */
int len; /* 指示线性链表中数据元素的个数 */
}LinkList;
/* bo2-6.c 具有实用意义的线性链表(存储结构由 c2-5.h 定义)的 24 个基本操作 */
Status MakeNode(Link *p,ElemType e)
{ /* 分配由 p 指向的值为 e 的结点,并返回 OK;若分配失败。则返回 ERROR */
*p=(Link)malloc(sizeof(LNode));
if(!*p)
评论0
最新资源