[c++]代码库
#include <iostream>
using namespace std;
typedef struct PNode
{
int data1;
int data2;
struct PNode *next;
}PNode,*Polynomial;
void Create(Polynomial &P)
{
P=new PNode;
P->next=NULL;
PNode *r=P;
int a;
int b;
while(cin>>a>>b)
{
PNode *s;
s=new PNode;
s->data1=a;
s->data2=b;
s->next=NULL;
r->next=s;
r=s;
}
}
void Printf(Polynomial &P)
{
if(P)
{
PNode *r=P->next;
int flag=1;
if(r->data2)
cout<<(r->data1*r->data2)<<" "<<r->data2-1;
else
{
cout<<"0 0";
flag=0;
}
r=r->next;
while(r&&flag&&r->data2)
{
cout<<" "<<r->data1*r->data2<<" "<<r->data2-1;
r=r->next;
}
}
}
int main()
{
Polynomial P;
Create(P);
Printf(P);
return 0;
}