C语言大作业全.docx

上传人:scccc 文档编号:13536062 上传时间:2022-01-14 格式:DOCX 页数:13 大小:46.62KB
返回 下载 相关 举报
C语言大作业全.docx_第1页
第1页 / 共13页
C语言大作业全.docx_第2页
第2页 / 共13页
C语言大作业全.docx_第3页
第3页 / 共13页
C语言大作业全.docx_第4页
第4页 / 共13页
C语言大作业全.docx_第5页
第5页 / 共13页
点击查看更多>>
资源描述

《C语言大作业全.docx》由会员分享,可在线阅读,更多相关《C语言大作业全.docx(13页珍藏版)》请在三一文库上搜索。

1、#include #include #include #include #include #define LEN sizeof(struct student)#define NULL 0int n,m;int k=1;struct studentchar num20;char name20;int age;char profession50;int maths;int english;int C_program;float ave;struct student * next;float ave(struct student * p1)float ave; ave=(float)(p1-math

2、s+p1-english+p1-C_program)/3; return ave;void save(struct student *head)struct student *p1 = head;FILE *outFile;outFile = fopen(, wb);if (outFile = NULL) printf(nFile error.);else while(p1 != NULL)fwrite(p1, sizeof(struct student), 1, outFile);p1 = p1-next;fclose(outFile);else head = (struct student

3、 *)malloc(sizeof(struct student);fread(head, sizeof(*head), 1, infile);p2 = head;while(fread(&record, sizeof(record), 1, infile);fwrite(p1, sizeof(struct student), 1, outFile);fclose(outFile);void sta(struct student * head,char array20,int max,int min)struct student *p1=head;int k=0;if(strcmp(array,

4、maths)=0)while(p1!=NULL)if(p1-maths=min&p1-mathsnext;printf(数学科目在4至9%沱间的人数为:dn,min,max,k);else if(strcmp(array,english)=0)while(p1!=NULL)if(p1-english=min&p1-englishnext;printf( 英语科目在 %d到%dN间的人数为:%dn,min,max,k);else if(strcmp(array,C_program)=0)while(p1!=NULL)if(p1-C_program=min&p1-C_programnext;pri

5、ntfC 语言科目在 cBU%dN间的人数为:dn,min,max,k;void exit()printf(tt);printf(*n);printf(tt);printf(*感谢使用 *n);printf(tt);printf(*n);k=0;void Chooseproject(int i) struct student * head=NULL;if(i=1)head = read(); print(head);else if(i=2)int p=1printf( 请选择按学号查询( 1)还是按姓名查询( 0) :); scanf(%d,&p);while(p!=1&p!=0)printf

6、( 输入错误 !);printf( 请选择学号查询( 1)还是姓名查询( 0) );scanf(%d,&p);if(p=1)head = read();char num20;printf( 请输入查询的学号 :n);scanf(%s,num);head=search_num(head,num);while(strcmp(num,0)!=0)printf( 是否继续查询(是就输学号,否就输 0) :n);scanf(%s,num);if(strcmp(num,0)=0)break;head=search_num(head,num);else if(p=0)head = read();char n

7、ame20;printf( 请输入查询的学号 :n); scanf(%s,name); head=search_name(head,name); while(strcmp(name,0)!=0)0):n);printf( 是否继续查询(是就输学号,否就输scanf(%s,name);if(strcmp(name,0)=0)break; head=search_name(head,name);else if(i=3)head = read();char num20;printf( 请输入要更改的学号 :n);scanf(%s,num);getchar();head=change(head,num

8、);print(head);while(strcmp(num,0)!=0)printf( 是否继续更改(是就输学号,否就输 0) :n);scanf(%s,num);getchar();if(strcmp(num,0)=0)break;head=change(head,num);print(head);else if(i=4)head=read();add(head);else if(i=5)char num20;head=read();printf( 请输入要删除的学号 :n);scanf(%s,num);getchar();head=del(head,num);print(head);el

9、se if(i=6)head = read();int i;printf(tt);printf(*1.学号排序 ;*n);printf(tt);printf(*2.平均成绩排序 ;*n);printf(tt);printf(*3.数学成绩排序 ;*n);printf(tt);printf(*4.英语成绩排序 ;*n);printf(tt);printf(*语言成绩排序 ;*n);printf 请输入相应的排序代号 :;scanf(%d,&i);sort_down(head,i);else if(i=7)head=read();int min,max;char subject20;printf(

10、tt);printf(*数学 (maths);*n);printf(tt);printf(*英语 (english);*n);*C语言(C_program);* n);printf( 请选择要统计的工程 :n);scanf(%s,subject);getchar();while(strcmp(subject,maths)!=0&strcmp(subject,english)!=0&strcmp(subject,C_program)!=0)printf 输入错误! ;printf(tt);printf(数学 (maths);*n);printf(tt);printf(英语 (english);*

11、n);printf(tt);printf(语言(C_program);*n);printf( 请选择要统计的工程 :n);scanf(%s,subject);getchar();printf( 请输入分数段的区间: );printf(区间上限: );scanf(%d,&max);printf( 区间下限: ); scanf(%d,&min);while(min=max)printf 输入的下限大于等于上限,错误! ;printf 请重新输入分数段的区间: ;printf( 区间上限: ); scanf(%d,max);printf( 区间下限: ); scanf(%d,min); sta(he

12、ad,subject,max,min);else if(i=8)printf(tt);printf(*n);printf(tt);printf(*感谢使用*n);printf(tt);printf(*n);息浏览;*k=0;printf(tt);printf(*2.信息查询 ;*n);printf(tt);printf(*3.信息修改 ;*n);printf(tt);printf(*4.信息添加 ;*n);printf(tt);printf(*5.信息删除 ;*n);printf(tt);printf(*6.信息排序 ;*n);*n);printf(tt);printf(*7.信息统计 ;*n

13、);printf(tt);printf(*8,退出系统 ;*n);printf 请选择工程: ;scanf(%d,&i);while(i8)printf 输入错误,请重新输入:n);printf(tt);printf(*1.信息浏览 ;*n);printf(tt);printf(*2.信息查询 ;*n);printf(tt);printf(*3.信息修改 ;*n);printf(tt);printf(*4.信息添加 ;*n);printf(tt);printf(*5.信息删除 ;*n);printf(tt);printf(*6.信息统计 ;*n);printf(tt);printf(*7,退出

14、系统 ;*n);printf 请重新选择工程: ;scanf(%d,&i);Chooseproject(i);int _tmain(int argc, _TCHAR* argv) struct student *head = NULL;printf(tt);printf(*n);I*n);I*);printf( 是否已经录入信息 n);char c;printf( 请输入 y 或 n:);c=getchar();getchar();while(c!=n&c!=y):n);printf( 输入错误,请重新输入 ( y 或 n) c=getchar();getchar();if(c=n)printf( 请输入学生成绩 :n);head=creat();while(k!=0)menu();system(pause);return 0;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1