C语言课程设计报告(学生成绩管理系统) 联系客服

发布时间 : 星期五 文章C语言课程设计报告(学生成绩管理系统)更新完毕开始阅读d223c0cf26d3240c844769eae009581b6ad9bd50

才会明白。其次,编程的确是一门很复杂的课程,必须花大量的时间去琢磨。而且编程是一门十分考验人的耐心的课程,犯了一点错误,你就必须认认真真地检查,不能有一点马虎,也不能有一点火燥。最重要的一点是,要想完成作业,必须查阅大量资料和询问师兄,这就考验了人的探讨能力和与他人的合作能力。

老实说,由于个人的c语言知识浅薄,我的这次作业还存在很多问题,可能也满足不了全部的设计要求。但是,自己已经尽力而为了,也亲自动手试过了,自己就不觉得遗憾了。以后,我还要必须努力学习,不断完善自己,虚心接受老师的教导,做出更好的系统。

四. 附录:源程序代码

#include #include #include #include

#define LEN sizeof(student) #define NULL 0

typedef struct student {

int num; /*学号*/

char name[20]; /*姓名*/ char sex[2]; /*性别*/ int score[4]; /*成绩*/ int sum; /*总成绩*/ struct student *next; }Student;

int n; /*声明一个全局变量*/

Student *cin(void);

Student *sort_1(Student *head,int); /*声明按学号排序函数*/

void sort_2(Student *head); /*声明按总分排序函数*/ void print(Student *head); /*声明显示函数*/

Student *sort_all(Student *head); /*声明排序函数*/ void find(Student *head); /*声明查询函数*/ Student *add_new(Student *head);

Student *cin() {

int flag;

Student *head,*p1,*p2; n=0;

head=(Student *)malloc(LEN); p2=head;

printf(\请输入第%d名学生的学号,学号为0表示结束输入:\ scanf(\while(getchar()!='\\n');

for(;flag;) /*输入每个学生的信息*/ { n++;

p1=(Student *)malloc(LEN); p1->num=flag;

printf(\请输入第%d名学生的姓名:\输入姓名*/ scanf(\

printf(\请输入第%d学生的性别:\输入性别*/ scanf(\

printf(\请输入第%d名学生的语文成绩:\输入语文成绩*/ scanf(\

printf(\请输入第%d名学生的数学成绩:\输入数学成绩*/ scanf(\

printf(\请输入第%d名学生的英语成绩:\输入英语成绩*/ scanf(\ printf(\请输入第%d名学生的c语言成绩:\输入c语言成绩*/ scanf(\

p1->sum=p1->score[0]+p1->score[1]+p1->score[2]+p1->score[3]; p2->next=p1; p2=p1;

printf(\请输入第%d名学生的学号,没有此学生则输入0表示结束:\ scanf(\ }

p2->next=NULL; printf(\return head; }

Student *sort_all(Student *head) /*定义排序函数*/ {

int choose; for(;;) {

printf(\大学生成绩统计排序 # # # #\\n\ printf(\按学生学号排序\\t #\\n\ printf(\按学生总分排序\\t #\\n\ printf(\单科高分及均分\\t #\\n\ printf(\显示当前学生成绩\\t #\\n\ printf(\返回上一级菜单\\t #\\n\ printf(\请输入你要执行的操作:\ scanf(\ while(getchar()!='\\n'); switch(choose) {

case 1: case 2: case 3: case 4: case 5:

case 6:head=sort_1(head,choose);break; case 7:print(head);sort_2(head);break; case 8:print(head);break; case 0:return head;

default: printf(\您的输入有误!请重新输入:\\n\\n\ } } }

Student *sort_1(Student *head,int choose) /*定义按学号排序函数*/ {

Student *p1,*p2=head->next,*pm,*px; Student mid;

if (!p2) return head;

for(p1=p2;p1->next!=NULL;p1=p1->next) {

pm=p1;

for(p2=p1->next;p2!=NULL;p2=p2->next) switch(choose) {

case 1:if (pm->num>p2->num) pm=p2;break; case 2:if (pm->sumsum) pm=p2;break;

case 3:if (pm->score[0]score[0]) pm=p2;break; case 4:if (pm->score[1]score[1]) pm=p2;break; case 5:if (pm->score[2]score[2]) pm=p2;break; case 6:if (pm->score[3]score[3]) pm=p2;break; } if (pm!=p1) {

mid=*pm; *pm=*p1; *p1=mid; px=pm->next;

pm->next=p1->next; p1->next=px; } }

printf(\排序后的成绩表为:\\n\print(head); return head; }

void sort_2(Student *head) /*定义按总分排序函数*/ {

Student *p=head->next;

int max_1,max_2,max_3,max_4,min_1,min_2,min_3,min_4; int max_sum,min_sum;

int sum_1=0,sum_2=0,sum_3=0,sum_4=0; float aver_1,aver_2,aver_3,aver_4,aver_sum; if (!p) return;

max_1=min_1=p->score[0];max_2=min_2=p->score[1]; max_3=min_3=p->score[2];max_4=min_4=p->score[3]; max_sum=min_sum=p->sum; for(;p;p=p->next) {

if (max_1score[0]) max_1=p->score[0];

else if (min_1>p->score[0]) min_1=p->score[0]; if (max_2score[1]) max_2=p->score[1];

else if (min_2>p->score[1]) min_2=p->score[1]; if (max_3score[2]) max_3=p->score[2];

else if (min_3>p->score[2]) min_3=p->score[2]; if (max_4score[3]) max_4=p->score[3];

else if (min_4>p->score[3]) min_4=p->score[3]; if (max_sumsum) max_sum=p->sum;

else if (min_sum>p->sum) min_sum=p->sum;

sum_1+=p->score[0];sum_2+=p->score[1];sum_3+=p->score[2];sum_4+=p->score[3];