logo - 刷刷题
下载APP
【简答题】

下列程序的主函数中,通过函数调用把 N 名学生的成绩放入一个带头节点的链表中, h 指向链 表的头节点。函数 fun 的功能是:找出 N 名学生中的最高分并返回,请补充程序。 #include #define N 8 Struct slist! Int s; 1 } ; Typedef struct slist STREC; Int fun ( STREC*h ) { int max=h->s; while ( 2 ) { if(maxs)max=h->s; 3 ; } Printf ( “%d”,max ) ; Return max; } STREC*creat(int*s)[ STREC*h,*p,*q; /*h 表示链表的头部 */ int i=0; h=p=(STREC*)malloc(sizeof(STREC)); p->s=0; while(i<="" p=""> q= ( STREC* ) malloc(sizeof(STREC)); p->s=s[i++]; p->next=q; 4 ; } p->next=NULL; return h; } int main(){ int s[N]={85,76,69,85,91,72,,87},max; STREC*head; 5 Max=fun(head); Printf(“max=%d\n”,max); Return 0; }

举报
参考答案:
参考解析:
.
刷刷题刷刷变学霸