发布网友 发布时间:2022-04-23 09:27
共1个回答
热心网友 时间:2023-05-16 15:16
咨询记录 · 回答于2021-12-13找一份没有全局变量的学生成绩管理系统的c语言程序代码#include#include#includetypedef struct Student{ int no; char name[10]; float score[3]; //three scores float average; //average score struct Student *next;}Student;void Initial(Student *p){ p=(Student*)malloc(sizeof(Student));//the head of the linklist p->next=NULL;}void Input(Student *p){ Student *stu=(Student*)malloc(sizeof(Student)); printf("学号:"); scanf("%d",&stu->no); printf("姓名:"); scanf("%s",stu->name); printf("成绩1:"); scanf("%f",&stu->score[0]); printf("成绩2:"); scanf("%f",&stu->score[1]); printf("成绩3:"); scanf("%f",&stu->score[2]); stu->average=(stu->score[0]+stu->score[1]+stu->score[2])/3; stu->next=NULL; Student *ps=(Student*)malloc(sizeof(Student)); ps=p; while(ps->next) ps=ps->next; ps->next=stu; //free(ps);}void Output(Student *p){ Student *ps=(Student*)malloc(sizeof(Student)); ps=p->next; printf("学号\t姓名\t成绩1\t成绩2\t成绩3\t平均分\n"); while(ps!=NULL) { printf("%d\t",ps->no); printf("%s\t",ps->name); pr