从键盘输入一批学生打得成绩,计算平均分。这个程序怎样编 急急急急...
发布网友
发布时间:2024-10-23 16:57
我来回答
共1个回答
热心网友
时间:2024-10-30 03:34
#include<stdio.h>
main()
{ typedef struct student{int sore; struct student next;
}students;
printf("请输入学生的成绩,结束请输入a");
students *head,*p,*q;int mun=0,avg,n=1;
head=(students *)malloc(sizeof(students));
scanf("%d",&head->sore);
mum=mun+head->sore;
p=head;
q=p;
while(p->sore!=a)
{
p=(students *)malloc(sizeof(students));
scanf("%d",&p->sore);
mum=mun+p->sore;
n=n+1;
q->next=p;
q=p;
}
avg=sum/n;
printf("学生的平均成绩为%d",avg)
}