#include<stdio.h>
#include<stdlib.h>
typedef struct student{
int num;
char name[100];
int grade;
struct student *next;
}*point;
point creatNde(){
int num,n=0;
scanf("%d",&num);
point p=(point)malloc(sizeof(struct student));
point head=p;
while(num!=0){
p->num=num;
scanf("%s",p->name);
scanf("%d",&p->grade);
p->next=(point)malloc(sizeof(struct student));
p=p->next;
scanf("%d",&num);
n++;
}
p->next=NULL;
return head;
}
int average(point p){
int sum=0,n=0;
while(p->next!=NULL){
sum=sum+p->grade;
n++;
p=p->next;
}
return sum/n;
}
void option(point p,int average){
while(p->next!=NULL){
if(p->grade>average){
printf("%d ",p->num);
printf("%d ",p->grade);
printf("%s ",p->name);
printf("\n");
}
p=p->next;
}
}
int main(){
point p=creatNde();
int m=average(p);
option(p,m);
}
用链表存储学生信息
猜你喜欢
转载自blog.csdn.net/qq_45560230/article/details/129337765
今日推荐
周排行