中国铁道建设出版
4.[程序如下]
struct link
{
int data;
link*next;
};
int sum(link *head)
{
} link *p; int s=0; p=head->next; while(p) { } s+=p->data; p=p->next; return s;
5.[程序如下]
#include<iostream.h>
struct node
{
int data;
node *next;
};
node *create( )
{
node *head ; //头指针
node *p , *pend ;
int a;
cout<<"请输入数据(为零表示结束输入):" ;
cin>>a;
head=0 ;
while(a!=0)
{
p=new node ;
p->data=a ;
if(head==0)
{
head=p ;
pend=p ;