欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    学生宿舍管理系统源代码(8页).doc

    • 资源ID:35950864       资源大小:155.50KB        全文页数:8页
    • 资源格式: DOC        下载积分:15金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要15金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    学生宿舍管理系统源代码(8页).doc

    - 数据结构 课程设计源代码 设计题目: 学生宿舍管理系统 院 系: 计算机学院 班 级: 软件1501 组 别: 六 组 长: 周佳理 组 员: 韩壮壮 陈义安 起止日期: 2016年12月20日2016年12月24日指导教师: 韩丽娜 -第 8 页-源代码: #define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>#include<string.h>void AppendNode(long studentID, char studentName15, char roomNumber4, char bedNumber4);/向链表中添加数据void DisplayNode(struct link *head);/打印链表中数据void Display(struct link *head);/表头格式控制void DeleteMemory(struct link *head);/删除链表所占用的内存void Save();/保存数据void Open();/打开数据void FindID();/按学号查找学生void FindName();/按姓名查找学生void InsertNodeNumber(long studentID, char studentName15, char roomNumber4, char bedNumber4);/按学号从小到大排序void NumberSorting();/排序void Menu();/菜单控制模块功能代码:/主函数int main()long studentID;char studentName15;char roomNumber4;char bedNumber4;/定义要输入学生信息的变量;char c;int menu;/保存要进行的选项;while (1) system("pause");Menu();printf("请输入要进行的操作:");scanf("%d", &menu);switch (menu) case 0:exit(0); break;case 1:printf("请输入Y或y来添加数据n");scanf(" %c", &c);while (c = 'y' | c = 'Y') printf("请输入学生学号:");scanf("%lld", &studentID);printf("请输入学生姓名:");scanf("%s", &studentName);printf("请输入房间号:");scanf("%s", &roomNumber);printf("请输入床位号:");scanf("%s", &bedNumber);AppendNode(studentID, studentName, roomNumber, bedNumber);printf("请输入Y或y来添加数据n");scanf(" %c", &c);Display(head); break;case 2: FindID(); break;case 3: FindName(); break;case 4:Display(head);/显示信息 break;case 5:NumberSorting();Display(head1);/排序后的学生信息head1 = NULL; break;case 6:Save(); break;case 7:Open(); break;default:printf("输入有误!请重新输入"); break;DeleteMemory(head);DeleteMemory(head1);system("pause");return 0;/菜单void Menu() system("cls");/清屏操作; printf("nnnnn"); printf("tt|.学生宿舍管理系统.|n");printf("tt|t 0.退出 |n");printf("tt|t 1.添加学生住宿信息 |n");printf("tt|t 2.查找学生(按学号)信息 |n");printf("tt|t 3.查找学生(按姓名)信息 |n");printf("tt|t 4.显示学生信息 |n");printf("tt|t 5.按学号排序 |n");printf("tt|t 6.保存信息 |n");printf("tt|t 7.打开信息 |n");printf("tt|.学生宿舍管理系统.|n");/表头格式控制void Display(struct link *head) printf("-n");printf(" 学号 姓名 宿舍号 床号 n");printf("-n"); DisplayNode(head);数据模块功能代码:/定义结构体typedef struct student long studentID; /学号char studentName15;/姓名char roomNumber4;/房间号char bedNumber4;/床号STU;/初始化链表struct link STU student;struct link *next;struct link *head = NULL;/保存输入的学生信息数据struct link *head1 = NULL;/保存排序后的学生信息数据/添加数据void AppendNode(long studentID, char studentName15, char roomNumber4, char bedNumber4) struct link *p = NULL, *pr = head;p = (struct link *) malloc(sizeof(struct link);if (p = NULL) printf("申请内存失败"); return;if (head = NULL) head = p;else while (pr->next != NULL) pr = pr->next;pr->next = p;p->student.studentID = studentID;strcpy(p->student.studentName, studentName);strcpy(p->student.roomNumber, roomNumber);strcpy(p->student.bedNumber,bedNumber);p->next = NULL; return;/打印数据void DisplayNode(struct link *head) struct link *p = head;if (p = NULL) return;printf("%lld%15s%13s%13s",p->student.studentID,p->student.studentName,p->student.roomNumber, p->student.bedNumber);printf("n"); p=p->next; DisplayNode(p);/保存链表中的数据void Save() FILE *fp;struct link *p = head;fp = fopen("demo.txt", "w");if (fp= NULL) printf("打开文件失败"); return;while (p != NULL) fprintf(fp,"%20lld%15s%5s%4s", p->student.studentID, p->student.studentName, p->student.roomNumber,p->student.bedNumber);p = p->next;fclose(fp); return;/将文件中获得的数据写入到链表中void Open() fflush(stdin);fflush(stdout);long studentID;char studentName15;char roomNumber4;char bedNumber4;FILE *fp; char c;fp = fopen("demo.txt", "a+");if (fp= NULL) printf("文件打开失败"); return;while (c = fgetc(fp)!=EOF) fscanf(fp, "%20lld", &studentID);fscanf(fp, "%15s", studentName);fscanf(fp, "%5s", roomNumber);fscanf(fp,"%4s",bedNumber);AppendNode(studentID, studentName, roomNumber, bedNumber);fclose(fp);功能模块功能代码:/排序函数void NumberSorting() struct link *p = head;struct link *p1 = head1;int sum = 0;if(p = NULL) printf("没有数据,无法排序"); return;while (p!=NULL) InsertNodeNumber(p->student.studentID,p->student.studentName,p->student.roomNumber, p->student.bedNumber);p = p->next;/按学号的从小到大排序void InsertNodeNumber(long studentID, char studentName15, char roomNumber4, char bedNumber4) struct link *pr = head1, *p = head1, *temp = NULL;p = (struct link *)malloc(sizeof(struct link);if (p = NULL) printf("内存申请失败"); return;p->next = NULL;p->student.studentID = studentID;strcpy(p->student.studentName, studentName);strcpy(p->student.roomNumber, roomNumber);strcpy(p->student.bedNumber,bedNumber);if (head1 = NULL) head1 = p;else while (pr->student.studentID < studentID&&pr->next != NULL) temp = pr; pr = pr->next;if (pr->student.studentID >= studentID) if (pr = head1) p->next = head1; head1 = p;else pr = temp; p->next = pr->next; pr->next = p;else pr->next = p;/删除链表所占用的内存void DeleteMemory(struct link *head) struct link *p = head, *pr = NULL;while (p != NULL) pr = p; p = p->next; free(pr);/按学号查找学生void FindID() struct link *p = head;long studentID=0;if (head = NULL) printf("没有数据查找"); return;printf("请输入你要查找的学生的学号:");scanf("%lld", &studentID);while (studentID != p->student.studentID&&p->next != NULL) p = p->next;if (p->student.studentID = studentID) printf("-n"); printf(" 学号 姓名 宿舍号 床号 n"); printf("-n"); printf("%lld%15s%13s%13s", p->student.studentID, p->student.studentName, p->student.roomNumber, p->student.bedNumber);else printf("没有你要查找的数据"); return;/按姓名查找学生void FindName() struct link *p = head;char studentName15 = ""if (head = NULL) printf("没有数据查找"); return;printf("请输入你要查找的学生的姓名:");scanf("%s", studentName);while (0!=strcmp(studentName,p->student.studentName)&&p->next != NULL) p = p->next;if (0=strcmp(studentName,p->student.studentName) printf("-n"); printf(" 学号 姓名 宿舍号 床号 n"); printf("-n"); printf("%lld%15s%13s%13s",p->student.studentID,p->student.studentName,p->student.roomNumber, p->student.bedNumber);else printf("没有你要查找的数据"); return;

    注意事项

    本文(学生宿舍管理系统源代码(8页).doc)为本站会员(1595****071)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开