新手菜鸟,求解答,谢谢
#include<iostream>//#include<stdlib.h> /* atoi() */
//#include"polyn.h"
using namespace std;
typedef struct
{
float coef;
int expn;
}term,ElemType;
typedef struct LNode
{
ElemType data;
struct LNode *next;
}*Link,*Position;
typedef struct
{
Link head;
int len;
}LinkList;
typedef LinkList polynomial;
ElemType e;
void CreatPolyn(polynomial&P,int m )
{
Link h;
h=P.head;
LNode *p;
p=new LNode;
for (int i=0;i<m;i++)
{
cin>>e.coef;
cin>>e.expn;
p->data.coef=e.coef;
// cout<<p->data.coef;
p->data.expn=e.expn;
// cout<<p->data.expn;
p->next=h;
h=p;
// cout<<p->data.coef;
// cout<<p->data.expn;
}
}
void PrintPolyn(polynomial&P,int m)
{
Link h;
h=P.head;
LNode *p;
p=new LNode;
cout<<"duoxiangshishi:";
for( int i=m;i>0;i--)
{
// p->next=h;
// h=p;
cout<<"a"<<endl;
p=h;
cout<<"a"<<endl;
p=p->next;
cout<<"a"<<endl;
e.coef=p->data.coef;
cout<<"a"<<endl;
e.expn=p->data.expn;
cout<<e.coef<<"X^"<<e.expn;
}
}
void main()
{
polynomial polyn;
int n;
cin>>n;
CreatPolyn(polyn,n);
PrintPolyn(polyn,n);
cin>>n;
}