链表类型定义如下:typedef struct nodeint data;struct node *next;}myList;m

链表类型定义如下:
typedef struct node
int data;
struct node *next;
}myList;
myList *head=NULL;
阅读程序,并回答下列问题。
void f30(int n)
{int i;
myList *p,*preOne,*preTwo;
preTwo=head=(myList*)malloc(sizeof(myList)); //建立头结点
head-> data=0;
preOne=head-> next=(myList*)malloc(sizeof(myList));
preOne-> data=l; //设置第一个数据结点
printf("%d,",preOne-> data);
for(i=1;i<n;i++)
{p=(myList*)malloc(sizeof(myList));
p-> data=preOne-> data+preTwo-> data;
printf("%d,",p-> data);
preOne-> next=p;
preTwo=preOne;
preOne=p;
}
p-> next=NULL;
return;
}
(1)执行程序f30(10)后程序的输出是什么?
(2)函数f30()的功能是什么?
【正确答案】:(1)1,1,2,3,5,8,13,21,34,55,
(2)创建了一个带头结点含n个数据结点的单链表L,L中前两个结点中的值是1,从第3个结点开始,值为其前面两结点中的值之和。