请编写函数fun(),它的功能是:将带头结点单向链表按data域由大到小排序(排序时不考虑头结点),主函数用随机函数为各节点data域赋值,头结点data域赋值为0。
[注意] 部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
[试题源程序]
#include <stdio.h>
#include<coni0.h>
struct as
int data;
struct aa *next;
;
void fun(struct aa *p)
main()
int i, n, m=100;
struct aa *h=NULL, *s=NULL,
*p=NULL;
clrscr()
s=(struct aa*) malloc(siZeof(struct aa));
h=s; h->data=0; h->next=NULL;
printf("Please input n:");
scanf("%d", &n);
for(i=1; i<=n; i++)
p=(struct aa*) malloc(sizeof(struct aa));
p->data=rand()%m; P->next=NULL;
printf("%d", P->data);
s->next=p; s=s->next;
fun(h);
printf("\n");
for(h=h->next; h!=NULL; h=h->nnext)
printf("%d", h->data);