欢迎来到天天文库
浏览记录
ID:27553705
大小:95.00 KB
页数:8页
时间:2018-12-03
《c课设学生成绩管理系统设计》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、#include#include//strcpy用至lj//#include#includetypedefstructnode"定义一个链表{longintstudent_number;floatmark[3];//三科成绩floatchengji;//T•均成绩charname[10];structnode*next;}node;/*node*student_create();node*student_sort(node*head);node*student_in
2、sert(node*head);node*student_delete(node*head);node*student_find(node*head);*/voidstudent_printl(node*head);voidstudent_print2(node*head);voidstudent_destroy(node*head);floatchengji(floata[],intn)//求平均成缋成绩函数{inti;floatsum=0;for(i=0;i3、}node*student_create()//student这个结构体{FILE*fp;//读入文件node*head/tail/p;//初始化一个头指针尾指针屮间变量intj;nodex,*m;m=&x;if((fp=fopen("message.txt,,,"r"))==NULL){printf("不能打开该文件!H);exit⑼;}head=tail=NULL;while(!feof(fp)){p=(node*)malloc(sizeof(node)};//动态分配空间调用stdlib这个函数库fscanf(fp,"%d%s%4、f%f%fent_numberrk[2]);//读入m->chengji=chengji(m->mark,3);//求三科成缋平均值p->student_number=m->student_number;p->chengjj=m->chengji;for(j=0;j<3;j++)p->mark[j]=m->mark[j];strcpy(p->name,m->name);p->next=NULL;if(head==NULL)head=tail=p;elsetail=tail->next=p;}fclose(fp);returnhead;}n5、ode*student_sort(node*head)//排序函数{node*first;node*tail;node*p_min;node*min;node*p;first=NULL;while(head!=NULL){for(p=head,min=head;p-〉next!=NULL;p=p->next){if(p->next->student_numberstudent_number){p_min=p;min=p->next;//小的前移}if(first==NULL){first=min;tail=min;}else{6、tail->next=min;tail=min;}if(min==head){head=head-〉next;}else{p_min->next=min-〉next;}}if(first!=NULL)tail->next=NULL;head=first;returnhead;}node*student_insert(node*head)//插入闲数{intj;node*p,*q,*s;s=(node*)malloc(sizeof(node));if(s==NULL){printf("内存分配不足">;exit⑼;}phntf("请依次7、输入要插入的学生的学号姓名语文英语数学An");scanf("%d%s",&s->student_number,&s->name);for(j=O;j<3;j++)scanf("%f",&s->mark[j]);s->chengji=chengji(s->markz3);if(head==NULL){head=s;s->next=NULL;}if(head->student_number>s->student_number){s-〉next=head;head=s;}elseif(head->student_number==s->stud8、ent_number){printf("通讯了巾已有该学生的信息!W");returnNULL;//该链表中己经有该学生的信息。}else{p=head;while((p->student_n
3、}node*student_create()//student这个结构体{FILE*fp;//读入文件node*head/tail/p;//初始化一个头指针尾指针屮间变量intj;nodex,*m;m=&x;if((fp=fopen("message.txt,,,"r"))==NULL){printf("不能打开该文件!H);exit⑼;}head=tail=NULL;while(!feof(fp)){p=(node*)malloc(sizeof(node)};//动态分配空间调用stdlib这个函数库fscanf(fp,"%d%s%
4、f%f%fent_numberrk[2]);//读入m->chengji=chengji(m->mark,3);//求三科成缋平均值p->student_number=m->student_number;p->chengjj=m->chengji;for(j=0;j<3;j++)p->mark[j]=m->mark[j];strcpy(p->name,m->name);p->next=NULL;if(head==NULL)head=tail=p;elsetail=tail->next=p;}fclose(fp);returnhead;}n
5、ode*student_sort(node*head)//排序函数{node*first;node*tail;node*p_min;node*min;node*p;first=NULL;while(head!=NULL){for(p=head,min=head;p-〉next!=NULL;p=p->next){if(p->next->student_numberstudent_number){p_min=p;min=p->next;//小的前移}if(first==NULL){first=min;tail=min;}else{
6、tail->next=min;tail=min;}if(min==head){head=head-〉next;}else{p_min->next=min-〉next;}}if(first!=NULL)tail->next=NULL;head=first;returnhead;}node*student_insert(node*head)//插入闲数{intj;node*p,*q,*s;s=(node*)malloc(sizeof(node));if(s==NULL){printf("内存分配不足">;exit⑼;}phntf("请依次
7、输入要插入的学生的学号姓名语文英语数学An");scanf("%d%s",&s->student_number,&s->name);for(j=O;j<3;j++)scanf("%f",&s->mark[j]);s->chengji=chengji(s->markz3);if(head==NULL){head=s;s->next=NULL;}if(head->student_number>s->student_number){s-〉next=head;head=s;}elseif(head->student_number==s->stud
8、ent_number){printf("通讯了巾已有该学生的信息!W");returnNULL;//该链表中己经有该学生的信息。}else{p=head;while((p->student_n
此文档下载收益归作者所有