花式馒头的培训:请会C语言编程的高手帮帮忙吧!真的是 急啊,晚上就要用了啊!

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 07:46:38
题目是:
结点的数据结构:
struct node
{int x;
struct node*next;
};创建一个链表,头指针为head; 编函数fmax(),求出链表中所有结点数据域值最大的结点位置,并由参数S返回给主函数。
void fmax(struct node*head,struct node*s)

void fmax(struct node *head,struct node *s)
{
struct node *p = head->next;
s = head;
while(p != NULL)
{
if(p->x > s->x)
{
s = p;
}
p = p->next;
}
}