如果链表的节点为:typedef struct node
{
double data;
struct node *next;
}Node; 则可以这样写: double avgfun(Node *h){ int n=0; double count=0; Node *p;
p = (Node *)malloc(sizeof(Node));
p = h;
while(p->next!=NULL)
{
p = p->next;
count += p->data; n++;
} return count/n;}