电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

C语言大作业(全).doc

21页
  • 卖家[上传人]:小**
  • 文档编号:90645169
  • 上传时间:2019-06-14
  • 文档格式:DOC
  • 文档大小:19.30KB
  • / 21 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • 1、#include stdafx.h#include stdio.h#include stdlib.h#include string.h#include malloc.h#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-maths+p1-english+p1-C_program)/3;return ave;void save(struct student *head)struct student *p1 = head;FILE *outFile;outFile = fopen(stu.bin, wb);if (outFile = NULL) pr

      2、intf(nFile error.); else while(p1 != NULL)fwrite(p1, sizeof(struct student), 1, outFile);p1 = p1-next;fclose(outFile);/将数据存入文档中void check(struct student * head,struct student * p1)struct student *h=head;for(m=0;mnext )if(strcmp( h-num,p1-num)=0)printf(输入号码重复n);printf(请重新输入学号:);scanf(%s,p1-num);getchar();check(head,p1);/检验学号是否重复struct student * creat()struct student * head;struct student *p1,*p2;n=0;p1=p2=(struct student *)malloc(LEN); printf(学号:n); scanf(%s,p1-num); getchar(); printf(姓名:n); gets

      3、(p1-name); printf(年龄:n); scanf(%d,&p1-age);getchar(); printf(专业:n); gets(p1-profession); printf(数学成绩:n); scanf(%d,&p1-maths); printf(英语成绩:n); scanf(%d,&p1-english); printf(C语言成绩:n); scanf(%d,&p1-C_program); head=NULL;while(strcmp(p1-num,0)!=0)n=n+1;if(n=1)head=p1; else p2-next=p1;p2=p1;p1=(struct student *)malloc(LEN); printf(学号:n); scanf(%s,p1-num); getchar();check(head,p1);/检查输入的学号是不是重复且是不是重复输错 printf(姓名:n); gets(p1-name); printf(年龄:n); scanf(%d,&p1-age);getchar(); printf(专业:n); gets(p1-profes

      4、sion); printf(数学成绩:n); scanf(%d,&p1-maths); printf(英语成绩:n); scanf(%d,&p1-english); printf(C语言成绩:n); scanf(%d,&p1-C_program);p2-next=NULL;save(head);return(head);/录入数据并将其保存至文档void print(struct student *head)struct student * p;printf(n这%d个学生的成绩为:n,n);printf(学号 姓名 年龄 专业 数学 英语 C语言 平均成绩n);p=head;if(head=NULL)printf(The info errorn);if(head!=NULL)while(p!=NULL)p-ave=ave(p);printf(%s%8s%8d%13s%9d%10d%9d%10.2f,p-num,p-name,p-age,p-profession,p-maths,p-english,p-C_program,p-ave);printf(n);p=p-next;/输出链表/

      5、struct student* read()struct student *head = NULL;struct student *p2 = head;struct student record;FILE *infile;infile = fopen(stu.bin, rb);n=1;if(infile = NULL)printf(nFile error.);else head = (struct student *)malloc(sizeof(struct student);fread(head, sizeof(*head), 1, infile);p2 = head;while(fread(&record, sizeof(record), 1, infile)/fread返回数据个数,结束和出错返回0;p2-next = (struct student *)malloc(sizeof(struct student);memcpy(p2-next, &record, sizeof(record); /复制结构体数据 p2 = p2-next; n=n+1;p2-next=NULL;f

      6、close(infile);return head;/从文件中读取数据struct student * search_num(struct student * head,char array20)struct student * p1;p1=head;if(head=NULL)printf(打开错误);return(head);while(strcmp(array,p1-num)!=0)&(p1-next!=NULL)p1=p1-next;/找到相应的学号if(strcmp(array,p1-num)=0)printf(学号 姓名 年龄 专业 数学 英语 C语言n);printf(%s%10s%10d%15s%11d%12d%11d,p1-num,p1-name,p1-age,p1-profession,p1-maths,p1-english,p1-C_program);printf(n);else printf(此学号不存在n);return(head); /按学号查询数据/struct student * search_name(struct student * head,char

      7、 array20)struct student * p1;p1=head;if(head=NULL)printf(打开错误);return(head);while(strcmp(array,p1-name)!=0)&(p1-next!=NULL)p1=p1-next;/找到相应的学号if(strcmp(array,p1-name)=0)printf(学号 姓名 年龄 专业 数学 英语 C语言n);printf(%s%10s%10d%15s%11d%12d%11d,p1-num,p1-name,p1-age,p1-profession,p1-maths,p1-english,p1-C_program);printf(n);else printf(此姓名不存在n);return(head); /按姓名查询数据/struct student * change(struct student * head,char array20)struct student *p1; p1=head; if(head=NULL) printf(打开错误!); return(head); while(strcmp(array,p1-num)!=0)&(p1-next!=NULL) p1=p1-next; /找到相应的学号 if(strcmp(array,p1-num)=0) printf(请输入更改的学号:n); printf(学号:n); scanf(%s,p1-num); getchar(); printf(姓名:n); gets(p1-name); printf(年龄:n); scanf(%d,&p1-age);getchar(); printf(专业:n); gets(p1-profession); printf(数学成绩:n); scanf(%d,&p1-maths); printf(英语成绩:n); scanf(%d,&p1-english); printf(C语言成绩:n); scanf(%d,&p1-

      《C语言大作业(全).doc》由会员小**分享,可在线阅读,更多相关《C语言大作业(全).doc》请在金锄头文库上搜索。

      点击阅读更多内容
    最新标签
    监控施工 信息化课堂中的合作学习结业作业七年级语文 发车时刻表 长途客运 入党志愿书填写模板精品 庆祝建党101周年多体裁诗歌朗诵素材汇编10篇唯一微庆祝 智能家居系统本科论文 心得感悟 雁楠中学 20230513224122 2022 公安主题党日 部编版四年级第三单元综合性学习课件 机关事务中心2022年全面依法治区工作总结及来年工作安排 入党积极分子自我推荐 世界水日ppt 关于构建更高水平的全民健身公共服务体系的意见 空气单元分析 哈里德课件 2022年乡村振兴驻村工作计划 空气教材分析 五年级下册科学教材分析 退役军人事务局季度工作总结 集装箱房合同 2021年财务报表 2022年继续教育公需课 2022年公需课 2022年日历每月一张 名词性从句在写作中的应用 局域网技术与局域网组建 施工网格 薪资体系 运维实施方案 硫酸安全技术 柔韧训练 既有居住建筑节能改造技术规程 建筑工地疫情防控 大型工程技术风险 磷酸二氢钾 2022年小学三年级语文下册教学总结例文 少儿美术-小花 2022年环保倡议书模板六篇 2022年监理辞职报告精选 2022年畅想未来记叙文精品 企业信息化建设与管理课程实验指导书范本 草房子读后感-第1篇 小数乘整数教学PPT课件人教版五年级数学上册 2022年教师个人工作计划范本-工作计划 国学小名士经典诵读电视大赛观后感诵读经典传承美德 医疗质量管理制度 2
    关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
    手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
    ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.