杭州化学教师招聘:谁来帮帮我看看这个C语言程序哪里错了

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/29 16:07:47
#include<malloc.h>
#include<stdio.h>
#include<stdlib.h>
#define len sizeof(struct student)
struct student
{
int num;
int score;
struct student *next;
}

int fun(struct student *h) 这里有个错
{
struct student *p1;
int min=0;
p1=h;
min=p1->score;
while(p1->next!=0)
{
if(p1->score<min)
min=p1->score;
p1=p1->next;
}
if(p1->score<min)
min=p1->score;
return min; 这里有个错
}

main()
{
struct student *h,*p1,*p2;
int min;
int n=0;
h=0;
p1=p2=(struct student *)malloc(len);
scanf("%d%d",&p1->num,&p1->score);
while(p1->num!=0)
{
n++;
if(n==1)h=p1;
if(n!=1)
{
(struct student *)malloc(len);
scanf("%d%d",&p1->num,&p1->score);
p2->next=p1;
p2=p1;
}
}
p1->next=0;
min=fun(h); 这里有个错
printf("%5d\n",min);
}

#include<malloc.h>
#include<stdio.h>
#include<stdlib.h>
#define len sizeof(struct student)
struct student
{
int num;
int score;
struct student *next;
} // 这里少了一个分号。