粗糙的成绩管理系统!
学C都有一段时间了!
所以想测试下自己的能力(经测试,能力不咋地

就做了个小小的成绩管理系统


虽然功能不怎么样,但也花了心思下去!欢迎糟蹋糟蹋












[ 本帖最后由 liangjinchao 于 2011-5-4 13:28 编辑 ]
void sort(ST *trans_head6)//函数功能:排序; (trans_head6是链表的头指针) { if(trans_head6==NULL) { printf("请先录入成绩!"); } else { ST *p=trans_head6->next; PT *ptr=(PT*)malloc(sizeof(PT)*count_stu),*ptr2,temp;//分配count_stu个PT单位; 注:count_stu是定义了的全局变量,用来记录链表中的人数! int i,j,k; ptr2=ptr; if(ptr==NULL) { printf("内存分配失败!程序将退出!\n"); exit(0); } else { while(p)//将链表结构中的数据导入到数组中 { ptr2->math=p->grade_math; ptr2->english=p->grade_english; ptr2->physics=p->grade_physics; ptr2->student_num=p->stu_num; ptr2->total_grade=p->total; p=p->next; ptr2++; } } for(i=0;i<count_stu;i++)//排序 { for(j=i+1;j<=count_stu;j++) { if((ptr+i)->total_grade<(ptr+j)->total_grade) { temp=*(ptr+i); *(ptr+i)=*(ptr+j); *(ptr+j)=temp; } } } printf("以下是排序后的成绩表:\n"); for(k=0;k<count_stu;k++) { printf("学号,数学成绩,英语成绩,物理成绩,总分\n"); printf("%d %f %f %f %f\n",(ptr+k)->student_num,(ptr+k)->math,(ptr+k)->english,(ptr+k)->physics,(ptr+k)->total_grade); } printf("最高分为:\n"); printf("学号:%d 总分:%f\n",ptr->student_num,ptr->total_grade); printf("最低分为:\n"); printf("学号:%d 总分:%f\n",(ptr+k-1)->student_num,(ptr+k-1)->total_grade); } }