教你如何用结构体指针玩转成绩
1、struct student* initstuscores(int len){ struct student{ int score; char *name;};

3、struct student*min = NULL; struct student*max = NULL; struct student *pstus = initstuscores(len); printmes(pstus, len); min = findminstu(pstus,len); max = findmaxstu(pstus,len);

5、int i; struct student *p = (struct student *)malloc(len*sizeof(stru艘早祓胂ct student));//在堆上开辟空间,函数结束调用也不会释放 for(i=0;i<len;i++){ printf("请输入名:\n"); p->name = (char *)malloc(128); scanf("%s",p->name); printf("请输入分数:\n"); scanf("%d",&(p->score)); p++; } return p-len;}

7、struct student* findmaxstu(struct student *p, int len){ int i稆糨孝汶; struct student*max; max = p; for(i=0;i<len;i++){ if(max->score < p->score){ max = p; } p++; } return max;}struct student* findminstu(struct student *p, int len){ int i; struct student*min; min = p; for(i=0;i<len;i++){ if(min->score > p->score){ min = p; } p++; } return min; }

9、运行程序
