一元多项式计算器

[复制链接]
查看11 | 回复2 | 2020-2-10 23:03:17 | 显示全部楼层 |阅读模式
#define TRUE 1
#define FALSE 0
#define OK
1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
typedef int Status;
typedef struct{//定义一元多项式变量
intExpn;
float Coef;
}ElemType;
typedef struct LNode{
ElemTypedata;
struct LNode *next;
}LNode, *LinkList;
Status CreatList(LinkList &L,int n)
{//操作结果:逆位输入n个元素的值,建立带表头节点的单链线性表L。
LinkList p;
int i,expn;
float coef;
L=(LinkList)malloc(sizeof(LNode));
L->next=NULL;
for(i=n;i>0;--i)
{
p=(LinkList)malloc(sizeof(LNode));
cout"
>coef

>>expn;
p->data.Coef=coef;
p->data.Expn=expn;
p->next=L->next;
L->next=p;
}//for
return OK;
}//CreatList
为什么无法实现链表的创建?

回复

使用道具 举报

千问 | 2020-2-10 23:03:17 | 显示全部楼层
拷过去后自己整一下编程风格//一元稀疏多项式计算器#include#include#defineOK1;#defineREAD(I)while(((I)=getchar())=='\n');//读入合法字符typedefintstatus;typedefstructPolyNode{floatcoef;intexpn;structPolyNode*next;}Poly,*P_Poly;statusCreatPoly(P_Poly*,int);//创建多项式链表voidOutP_Poly...
回复

使用道具 举报

千问 | 2020-2-10 23:03:17 | 显示全部楼层
这一个程序可以用#include#include#define LEN sizeof(struct entry) struct entry{ int mod; int exp; struct entry *next; }; void init(struct entry *strPe...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行