为什么我的程序编译链接都没有错,得出来的结果却是零,而且还有一个NULL pointer assignment,大神帮帮忙
#include<stdio.h>#include<stdlib.h>
#include<math.h>
#define NULL 0
typedef struct{
int coaf;
int expn;
}polym;
typedef struct LNode
{
polym data;
struct LNode *next;
}Node,*sqlist;
void inistlist(sqlist *a,int n)
{
a=(sqlist*)malloc(n*sizeof(polym)) ;
printf("Please input the 0 Node:");
scanf("%d%d",(*a)->data.coaf,(*a)->data.expn);
(*a)->next=NULL;
}
void creatlist(sqlist *a,int n)
{
int i;
Node *p=NULL;
inistlist(a,n);
for(i=1;i<n;i++)
{
printf("Please input the %d Node:",i);
scanf("%d%d",&p->data.coaf,&p->data.expn);
(*a)->next=p;
}
p->next=NULL;
}
double sumarr(sqlist *a,int x)
{
int i;
double sum=0,temp;
while((*a)->next!=NULL)
{
temp=pow(x,(*a)->data.expn);
sum+= (*a)->data.coaf*temp;
*a=(*a)->next;
}
return sum;
}
int main()
{
sqlist *a=NULL;
int n,x;
double sum;
printf("Please input the n,x:");
scanf("%d%d",&n,&x);
creatlist(a,n);
sum=sumarr(a,x);
printf("Sum=%f\n",sum);
return 0;
}