C++课程设计 文件管理系统
- 格式:docx
- 大小:130.87 KB
- 文档页数:21
#include〈stdio.h〉#include<windows.h〉#include〈string。
h〉#include<conio。
h>#define M 100struct books{char tsmc[12];inttsbh;float dj;char zz[12];char czzt[12];char xm[12];char xb[12];intxh; }s[M];int N;bool flag;intmain (){intsele;flag=0;sele=1;void sr();void cx();void sc();void js();void hs();void tc();void jsh();//system ("tsgl”);printf("\n\n");printf(" ************************\n"); printf(" 1:输入2:查询3:删除\n");printf(”4:借书5:还书0:退出\n");printf(” ************************\n"); while(1){printf(”\n\n请输入功能序号:");scanf (”%d",&sele);if(sele>=0 && sele<=5){switch(sele){case 1:sr();break;case 2:cx();break;case 3:sc();break;case 4:js();break;case 5:hs();break;case 0:jsh();break;}if(flag)break;printf(”\n\n");printf(” ************************\n”); printf(" 1:输入2:查询3:删除\n");printf(”4:借书5:还书0:退出\n”);printf(” ************************\n”);}else{printf(”输入错误请再次输入|\n\n");printf("\n\n");printf(” ************************\n”);printf(" 1:输入2:查询3:删除\n”);printf(”4:借书5:还书0:退出\n");printf(" ************************\n");}printf("\n\n让任意键继续\n”);} //wr_file();}/******主函数***//*********输入*********/void sr(){intn,i;N=0;printf("可输入的书本数:");scanf("%d",&n);N=n+N;printf("请输入相关信息:\n");for(i=1;i<=n;i++){printf(”图书名称:”);scanf(”%s",s[N-n-1+i]。
c语言管理系统设计源代码以下是一个简单的C语言管理系统示例,用于管理学生信息。
该系统可以添加、删除、修改和查找学生信息。
c复制代码#include<stdio.h>#include<stdlib.h>#include<string.h>struct student {char name[50];int roll;float marks;};struct student students[100];int count = 0;void add_student() {struct student new_student;printf("Enter name: ");scanf("%s", new_);printf("Enter roll number: ");scanf("%d", &new_student.roll);printf("Enter marks: ");scanf("%f", &new_student.marks);students[count] = new_student;count++;}void delete_student() {int index;printf("Enter index of student to delete: ");scanf("%d", &index);for (int i = index; i < count - 1; i++) {students[i] = students[i + 1];}count--;}void modify_student() {int index;struct student new_student;printf("Enter index of student to modify: "); scanf("%d", &index);printf("Enter new name: ");scanf("%s", new_);printf("Enter new roll number: ");scanf("%d", &new_student.roll);printf("Enter new marks: ");scanf("%f", &new_student.marks);students[index] = new_student;}void find_student() {char name[50];printf("Enter name of student to find: "); scanf("%s", name);for (int i = 0; i < count; i++) {if (strcmp(students[i].name, name) == 0) { printf("Roll number: %d\n", students[i].roll); printf("Marks: %.2f\n", students[i].marks); return;}}printf("Student not found.\n");}int main() {int choice;do {printf("\nMenu:\n");printf("1. Add student\n");printf("2. Delete student\n");printf("3. Modify student\n");printf("4. Find student\n");printf("5. Exit\n");printf("Enter choice: ");scanf("%d", &choice);switch (choice) {case1: add_student(); break;case2: delete_student(); break;case3: modify_student(); break;case4: find_student(); break;case5: exit(0); break; // exit the program here, otherwise the loop will keep running indefinitely, as it is in the do-while loop above. We are not returning, but rather exiting the program completely, so we do not need to return anything. The return value of main is always 0, and this is how the program exits. If you want to return a value other than 0, you can do so like this: return 1; or return -1; or return any other integer value you want to represent an error condition. The operating system will interpret this as the program's exit status. In this case, it will be seen as successful, as it is returning 0. The return value of main is not used for anything in this program, but it can be used in other programs to determine whether the program exited successfully or with an error. For example, if you were writing a shell script that executed this program and needed to know if it was successful or not, you could check the return value of the program and act accordingly. This is a common practice in programming, and it is important to understand how it works so that you can use it effectively in your own programs.。
操作系统课程设计文件管理系统1. 引言文件管理是操作系统中的一个重要模块,负责对计算机中的文件进行管理和组织。
在操作系统课程设计中,设计一个文件管理系统是一个很有挑战性的任务,需要考虑到文件的创建、打开、读取、写入、删除等功能,并且要确保文件的安全性和可靠性。
本文将详细介绍文件管理系统的设计与实现。
2. 需求分析为了满足用户对文件管理的需要,我们需要对文件管理系统的需求进行分析。
在这个文件管理系统中,用户应该能够执行以下操作:•文件的创建和命名•文件的打开和关闭•文件的读取和写入•文件的删除和修改•文件的搜索和查找除此之外,还要考虑到对文件权限的管理,可以设置不同用户对文件的不同访问权限,以保障文件的安全性。
3. 概要设计概要设计是对文件管理系统的整体架构和功能进行规划和设计。
文件管理系统可以采用层次结构的设计方式,分为用户界面、文件管理模块和存储管理模块。
3.1 用户界面用户界面是用户与文件管理系统进行交互的接口,可以通过命令行或者图形界面来实现。
在用户界面中,用户可以输入相关指令来执行对文件的操作,如创建文件、打开文件、读取文件等。
3.2 文件管理模块文件管理模块是文件管理系统的核心模块,负责对文件进行创建、打开、读取、写入、删除等操作。
在文件管理模块中,需要维护一个文件目录表来记录文件的基本信息,如文件名、文件大小、文件权限等。
还需要考虑到文件的分配和回收,可以使用位示图等方式进行实现。
3.3 存储管理模块存储管理模块负责对文件进行存储和管理,包括磁盘空间的分配和回收。
在存储管理模块中,可以采用文件分配表或者索引节点进行存储方式的选择。
4. 详细设计在详细设计阶段,需要对概要设计中的每个模块进行详细设计,并确定各个模块之间的接口和数据结构。
4.1 用户界面设计用户界面设计可以采用命令行方式进行实现。
用户可以通过命令输入来执行相应的文件管理操作。
可以设计一系列命令,如create用于创建文件,open用于打开文件,read用于读取文件等。
C#系统开发能力综合实训---—教务管理系统设计与实现系别:班级:姓名:学号:日期:一、课程设计题目:教务管理系统二、课程设计目的一个综合性的实践环节,通过课程设计促进知识的复习和所学知识的巩固.并利用所学知识能够利用VS2005开发一个简易的教务管理系统。
三、课程设计要求需求分析在科学技术飞速发展的今天,计算机科学及互联网日渐成熟,其强大的功能已为人们深刻认识,它已经进入人类社会的各个领域并发挥着越来越重要的作用。
各行各业的人们无须经过特别的训练就能够使用电脑完成许许多多复杂的工作.现如今学校招生越来越多,必然就会有大量的学生信息需要处理。
如果只靠人力来完成,这将会变成一项非常繁琐、复杂的工作,而且还会出现很多意想不到的错误,给管理这些数据带来了很大的不便,也越来越不适合学校发展的需要。
随着学校的规模不断扩大,学生数量急剧增加,有关学生的各种信息量也成倍增长。
面对庞大的信息量,就需要建立一个高效快捷的教务管理系统迫在眉睫。
其目的是为了提高学校对信息的管理,减少人力资源的开支和浪费,从而提高学校在各方面的工作效率.通过这样的系统,可以做到信息的规范管理、科学统计和快速的查询,从而减少管理方面的工作量。
由于计算机和网络的普及,若建立一个C/S结构的教务管理系统,学生便可以通过网络来查询成绩并且查询自己的有关信息,使得学校的教务管理工作系统化,规范化,自动化,大大提高了学校管理教务信息的效率。
教务管理系统是一个庞大而复杂的系统,它包括对院系资料的管理,对课程资料的管理,对学生资料的管理和对学生成绩的管理等等主要的功能.教务管理系统是每个学校的一项必不可少的内容,它的好坏直接影响到学校里的主要工作,一旦此系统瘫痪,学校将会受到非常严重的损失,也会影响到每一个学生.所以现如今设计一个功能完整、操作简单以及界面友好的教务管理系统变得非常重要。
四、课程设计内容1.系统总体结构2。
数据库模块由用户的需求分析和概念结构设计,最终设计了名为教务管理数据库的数据库,一部分数据库中的表如下所示:表1—1 admin表表1-2 teacher表表1—3 student表表1—4 class表2.运行界面如图1-1所示:图 1—1 主界面图 1—2 课程界面五、课程设计核心代码Login.aspx代码如下:protected void Login1_Authenticate(object sender,AuthenticateEventArgs e){try{string usertype = ((System。
课程设计报告( 20 --20 年度第学期)课程名称:操作系统实验课设题目:文件系统的实现院系:控制与计算机工程学院班级:姓名:指导教师:设计周数:一周成绩:20 年月日设计报告内容一、需求分析用C或C++编写和调试一个文件系统,功能使用命令行的方式实现。
模拟文件管理的工作过程。
加深理解文件系统的内部功能和内部实现。
用内存模拟磁盘用结构体数组描述个不同的磁盘区域。
磁盘的存取单元是磁盘块,一个盘块的大小是64字节。
每个目录项16个字节,目录项下只允许建立4个子目录或者文件。
i-node位图1块64个字节,共512位,可以描述512个i-node的使用情况。
i-node的长度是16字节。
文件超过两个盘块会用到一级索引。
每个以及索引盘块(64字节)可以包含16个盘块号。
文件包含目录文件和文本文件。
实现Format,Mkfile,Mkdir,Cd,Delfile,Deldir,Dir,Copy,Open,Viewinodebitmap,V iewblockbitmap等功能。
二、整体功能及设计(功能划分及流程图)1、数据结构:struct DirectoryEntry{ //目录项char name[8]; //文件或目录名int dirid; //目录标志(0为文件,1为目录)int inodenumber; //i-node编号};struct DirectoryEntryInBlock{DirectoryEntry de[4]; //每个目录项大小为16字节,64字节空间最多可以存储4个目录项int num; //磁盘块存储的目录项数目};struct indexaddressstruct{int indexaddress[16]; //每个索引块大小为4字节,64字节空间最多可以存储16个索引块号int num; //索引块存储的索引数目};union Block{ //单个盘块64个字节大小可以存储文件内容或者存储目录项或者存储索引块号char space[64]; //空间大小为64个字节用于存储文件内容DirectoryEntryInBlock deib;indexaddressstruct ias;};struct inodeStruct{ //i-node结构int blockamount; //盘块数int directblockaddress1,directblockaddress2; //直接盘块地址*2int stairindexaddress; //一级索引地址};struct DiskBlock{ //磁盘布局DirectoryEntry rootdirectory[4]; //根目录,最多4个目录项char inodebitmap[512]; //512个i-node状态char blockbitmap[1024]; //1024个磁盘块状态inodeStruct inode[512]; //512个i-node存储区Block datablock[1024]; //数据块存储区};static DiskBlock db; //全局磁盘变量int rootdirectoryamount; //用于记录根目录的使用数目,最大为4 int inodeamount; //用于记录i-node的使用数目,最大为512int datablockamount; //用于记录数据块的使用数目,最大为1024int spaceamount; //用于记录数据块中64位字节的使用数目,最大为64 DirectoryEntry filelist[500]; //用于记录文件方便遍历检索DirectoryEntry directorylist[500]; //用于记录目录方便int fileamount; //用于记录文件数目int directoryamount; //用于记录目录的数目char localposition[8]; //用于记录当前位置2、文件系统相关图(1)文件系统简单结构图如图1所示。
c语言课程设计信息管理系统一、教学目标本课程的教学目标是使学生掌握C语言程序设计的基本知识和技能,能够运用C语言设计简单的信息管理系统。
具体分为以下三个部分:1.知识目标:学生需要掌握C语言的基本语法、数据类型、运算符、控制结构、函数等基本知识,了解面向过程的编程思想。
2.技能目标:学生能够运用C语言编写简单的程序,具备调试和解决问题的能力,能够独立完成一个小型信息管理系统的设计。
3.情感态度价值观目标:培养学生对计算机科学的兴趣和热情,提高学生解决问题的能力,培养学生的创新精神和团队合作意识。
二、教学内容本课程的教学内容主要包括C语言的基本语法、数据类型、运算符、控制结构、函数等基本知识,以及面向过程的编程思想。
具体安排如下:1.第一章:C语言基础知识,介绍C语言的基本语法、数据类型、运算符等。
2.第二章:控制结构,介绍条件语句、循环语句等控制结构。
3.第三章:函数,介绍函数的定义、声明和调用,以及递归函数。
4.第四章:数组和字符串,介绍一维数组、多维数组、字符串的基本操作。
5.第五章:指针,介绍指针的概念、运算和应用。
6.第六章:结构体和联合体,介绍结构体、联合体的定义和应用。
7.第七章:文件操作,介绍文件的概念、文件操作函数和文件指针。
8.第八章:面向过程的编程思想,介绍模块化编程、函数指针等概念。
三、教学方法本课程的教学方法采用讲授法、案例分析法和实验法相结合的方式。
在教学过程中,教师会通过讲解和示例让学生掌握C语言的基本知识和编程技巧,同时通过案例分析法让学生了解信息管理系统的实现过程。
此外,实验法将用于培养学生的实际编程能力和问题解决能力。
四、教学资源本课程的教学资源包括教材、多媒体资料和实验设备。
教材选用《C程序设计语言》(K&R)作为主要参考书,多媒体资料包括教学PPT、视频教程等,实验设备包括计算机、网络等。
这些教学资源将用于支持教学内容和教学方法的实施,丰富学生的学习体验。
c语言课程设计优秀案例C语言是一门广泛应用于计算机科学领域的编程语言,它具有高效、简洁、可移植等特点,因此在计算机科学领域中得到了广泛的应用。
在C语言课程设计中,学生需要通过实践来掌握C语言的基本语法和编程思想,同时也需要通过设计优秀的案例来提高自己的编程能力。
下面是10个优秀的C语言课程设计案例。
1. 学生成绩管理系统这个案例要求学生设计一个学生成绩管理系统,可以实现学生信息的录入、查询、修改和删除,同时还可以计算学生的平均成绩、最高成绩和最低成绩等统计信息。
2. 简单计算器这个案例要求学生设计一个简单的计算器,可以实现加、减、乘、除等基本运算,同时还可以实现括号、小数点和负数等高级运算。
3. 迷宫游戏这个案例要求学生设计一个迷宫游戏,可以实现玩家在迷宫中寻找出口的过程,同时还可以实现随机生成迷宫、计时和计分等功能。
4. 图书管理系统这个案例要求学生设计一个图书管理系统,可以实现图书信息的录入、查询、修改和删除,同时还可以实现借书和还书等功能。
5. 简单的文件管理器这个案例要求学生设计一个简单的文件管理器,可以实现文件的创建、删除、复制和移动等基本操作,同时还可以实现文件夹的创建和删除等高级操作。
6. 简单的网络聊天程序这个案例要求学生设计一个简单的网络聊天程序,可以实现用户之间的文字聊天和文件传输等功能,同时还可以实现用户登录和注册等操作。
7. 简单的音乐播放器这个案例要求学生设计一个简单的音乐播放器,可以实现音乐的播放、暂停、停止和跳转等基本操作,同时还可以实现音乐列表的管理和歌词显示等高级功能。
8. 简单的游戏开发这个案例要求学生设计一个简单的游戏,可以实现玩家的移动、攻击和防御等基本操作,同时还可以实现关卡设计和游戏难度调整等高级功能。
9. 简单的人工智能程序这个案例要求学生设计一个简单的人工智能程序,可以实现基本的语音识别、图像识别和自然语言处理等功能,同时还可以实现机器学习和深度学习等高级功能。
c语言课程设计(学生信息管理系统)一、系统功能学生信息管理系统是一款基于C语言开发的数据管理程序,可实现对学生信息的增删改查等功能。
具体功能列表如下: a. 添加学生信息:可根据学生的基本信息,如学生学号、姓名、性别、地址、联系电话等,依次记录入系统; b. 删除学生信息:可根据学生学号、姓名等信息,从系统中删除不必要的学生信息; c. 修改学生信息:可根据已有的学生信息,修改学生某些属性内容,以更新系统中的数据; d. 查看学生信息:可根据学生学号、姓名等信息,查看指定学生的所有信息及多种查询功能; e. 数据保存功能:可将当前系统中的学生信息,保存成文件的形式; f. 备份/恢复功能:可对学生信息文件进行备份并对备份文件进行恢复; g. 查询统计功能:可根据学院代号、专业代号等信息,进行不同的查询统计; h. 排序功能:可根据学生学号、姓名等信息,对学生信息进行排序; i. 帮助功能:可提供详细的使用帮助文档,以帮助用户更好地使用系统;二、程序实现及结构1. 主程序:此程序用于控制整个系统的运行,可实现系统菜单显示、功能调用及功能切换等功能,可根据用户的操作需求,调用其他子程序实现各项功能。
2. 子程序:此程序是系统的主要部分,可实现学生信息的增删改查等功能,并可支持学生信息的备份,恢复,排序及查询统计等功能,用于实现主程序调用的功能。
3. 管理模块:此模块可实现对用户的登录及注册功能,可检测用户登录及注册的账号是否正确,以及是否有权限使用系统;4. 数据库模块:此模块可实现对学生信息的存储及调用,便于对各类学生信息进行更方便的管理。
此模块还可以负责系统的备份及恢复功能的实现。
5. 图形界面模块:此模块负责实现系统的图形化界面,使用户可以更加友好地操作系统,可以根据用户的需求,随时更改系统界面设置。
三、程序设计学生信息管理系统的设计主要有四个部分:1. 主程序:主程序的设计要求负责控制整个系统的运行,并根据用户的操作调用子程序实现各个功能。
课程设计文件管理系统一、教学目标本课程旨在让学生了解和掌握课程设计文件管理系统的基本概念、原理和方法,培养学生运用课程设计文件管理系统进行课程设计和管理的实践能力,提高学生的信息素养和团队协作能力。
1.了解课程设计文件管理系统的基本概念和作用。
2.掌握课程设计文件管理系统的基本操作方法和技巧。
3.理解课程设计文件管理系统在课程设计和项目管理中的应用。
4.能够独立使用课程设计文件管理系统进行课程设计和管理。
5.能够运用课程设计文件管理系统进行团队协作和沟通。
6.能够根据实际需求,选择合适的课程设计文件管理系统进行课程设计和项目管理。
情感态度价值观目标:1.培养学生对课程设计文件管理系统的兴趣和热情,提高学生对信息技术的接受度和运用能力。
2.培养学生团队协作意识和能力,使学生认识到团队协作在课程设计和项目管理中的重要性。
3.培养学生对课程设计和项目管理的认真态度和责任心,提高学生的职业素养。
二、教学内容本课程的教学内容主要包括课程设计文件管理系统的基本概念、基本操作和应用实践。
1.课程设计文件管理系统的基本概念:介绍课程设计文件管理系统的基本概念、特点和作用。
2.课程设计文件管理系统的基本操作:讲解课程设计文件管理系统的安装、使用和维护方法,以及如何进行课程设计和项目管理。
3.课程设计文件管理系统在课程设计和项目管理中的应用实践:通过实际案例分析,使学生掌握课程设计文件管理系统在课程设计和项目管理中的具体应用。
三、教学方法为了提高教学效果,本课程将采用多种教学方法相结合的方式进行教学。
1.讲授法:通过教师的讲解,使学生了解课程设计文件管理系统的基本概念和原理。
2.案例分析法:通过分析实际案例,使学生掌握课程设计文件管理系统在课程设计和项目管理中的应用。
3.实验法:通过实际操作,使学生熟练掌握课程设计文件管理系统的基本操作方法。
4.小组讨论法:通过小组讨论,培养学生的团队协作能力和沟通能力。
四、教学资源为了支持本课程的教学,我们将准备以下教学资源:1.教材:选用合适的课程设计文件管理系统教材,为学生提供系统的理论知识。
c语言课程设计图书管理系统一、教学目标本课程的教学目标是使学生掌握C语言编程的基本知识,能够运用C语言设计简单的图书管理系统。
具体目标如下:1.知识目标:•掌握C语言的基本语法和数据结构。
•理解图书管理系统的需求和设计原理。
2.技能目标:•能够使用C语言进行程序设计和调试。
•能够独立设计并实现图书管理系统的功能模块。
3.情感态度价值观目标:•培养学生的编程兴趣和自主学习能力。
•培养学生的团队协作能力和问题解决能力。
二、教学内容本课程的教学内容主要包括C语言的基本语法、数据结构以及图书管理系统的需求分析和设计。
具体内容如下:1.C语言的基本语法:•变量和数据类型•运算符和表达式•函数和数组2.数据结构:3.图书管理系统的需求分析和设计:•用户界面设计•图书信息管理•借阅信息管理•查询和统计功能三、教学方法本课程采用多种教学方法相结合的方式,以激发学生的学习兴趣和主动性。
具体方法如下:1.讲授法:通过讲解C语言的基本语法和数据结构,使学生掌握相关知识。
2.案例分析法:通过分析图书管理系统的需求和设计案例,使学生理解并能够独立设计类似的系统。
3.实验法:通过编写和调试代码,使学生掌握C语言编程的技巧和方法。
四、教学资源本课程所需的教学资源包括教材、参考书、多媒体资料和实验设备。
具体如下:1.教材:选用权威出版的C语言编程教材,为学生提供系统的学习资料。
2.参考书:提供相关的C语言编程参考书籍,供学生深入学习和参考。
3.多媒体资料:制作课件和教学视频,以图文并茂的方式呈现教学内容,增强学生的学习兴趣。
4.实验设备:提供计算机和相关的编程工具,为学生提供实践编程的机会。
五、教学评估本课程的评估方式包括平时表现、作业和考试三个部分,以保证评估的客观性和公正性。
1.平时表现:通过课堂参与、提问和小组讨论等方式评估学生的学习态度和参与程度。
2.作业:布置适量的编程作业,评估学生的编程能力和对知识的掌握程度。
3.考试:进行期中和期末考试,评估学生的综合运用能力和对知识的全面掌握。
操作系统文件管理系统课程设计
操作系统文件管理系统课程设计一般包括以下内容:
1. 基本概念和原理:介绍文件管理系统的基本概念和原理,包括文件、目录、文件系统、文件操作等。
2. 设计需求分析:明确设计需求,包括基本功能、用户需求、性能要求等。
3. 文件存储结构的设计:设计文件存储结构,包括文件分配方式、文件存储结构、文件目录结构、文件保护等。
4. 文件操作的实现:实现文件的创建、打开、读写、删除等基本操作,以及文件的复制、移动、重命名等高级操作。
5. 目录管理的实现:实现目录的创建、删除、重命名等操作,以及目录的遍历和搜索等功能。
6. 文件系统的实现:实现文件系统的格式化、挂载、卸载等操作,以及文件系统的安全性和可靠性保障。
7. 用户界面的设计:设计用户界面,包括命令行界面和图形界面,以方便用户进行文件管理操作。
8. 系统测试和调试:对系统进行测试和调试,包括单元测试、集成测试、性能测试等,以确保系统的稳定性和可靠性。
9. 报告撰写和展示:根据课程设计的要求,编写设计报告和展示文稿,介绍系统的设计思路、实现方法和成果。
以上是一个基本的操作系统文件管理系统课程设计的内容,具体可以根据教师的要求和课程的安排进行适当调整和扩展。
人事管理系统前言:现代计算机技术的发展为人们的学习、生活、工作提供了很大的帮助, 各行各业都需要特定计算系统的运用, 我们需要了解这些系统是怎么样为我们服务以及他们是怎样编辑出来的。
我们需要学习C语言编程, 根据课堂讲授内容, 做相应的自主练习, 消化课堂所讲解的内容;通过调试典型例题或习题积累调试C程序的经验;通过完成辅导教材中的编程题, 逐渐培养编程能力、用计算机解决实际问题的能力, 能够按照要求编辑一些基本的程序, 提高自己的思维能力。
题目:(1)某高校主要人员有: 在职人员(行政人员、教师、一般员工)、退休人员及临时工。
现在需要储存这些人员的人事档案信息, 内容包括编号、姓名、年龄、职务、职称、政治面貌、最高学历、任职时间、来院时间、人员类别。
其中, 人员编号唯一, 不能重复。
(2)添加删除功能:能根据学院人事的变动情况, 添加删除记录。
(3)查询功能: 能根据编号和姓名进行查询。
(4)编辑功能(高级): 根据查询对相应的记录进行修改并记录。
(5)统计功能:能根据多种参数进行人员的统计(在职人数、党员人数、女工人数, 高学历高职称人数), 统计要求同时显示被统计着的信息。
排序功能: 按照年龄、来院时间进行排序。
保存功能: 能对输入的数据进行相应的存储。
分析:我们编辑的程序要能够满足题目的要求, 可以进行这么多的功能的计算!但是在开始我们运行使用程序的时候必须要知道我们要运用这些功能中的哪一个!这就要求我们可以程序中任意选择我们所需要的功能!很显然我们要编辑存储人员的信息自然要运用到文件!而人员的信息必须要以结构体的形式来表示才能够方便我们提取信息!我们选择了要运行的功能分支之后!这些功能是以主函数以外的被调函数!当有需要时被调函数还可以调用其他的被吊函数!例如我们题目中的统计和查询功能, 就可以用这种方式来编辑程序!方便清楚!设计:很显然主程序要用到SWICTH函数, 这样可以选择要运行的那个功能的函数来执行, 而其他的功能函数则不必运行!三、解题思路1.定义结构struct staff{char num[10];char name[20];char sex[10];int age;char title[20];char p_landscape[30];char Qualifications[30];int Service_time;char come_time[30];char category[30];}staff[100];2.主程序进入主菜单函数void main(){menu();}/*******************主菜单函数**********************/void menu(){char w0;do{system("cls");fflush(stdin); /*清除缓冲区输入*/puts("***********************高校人事管理系统**********************\n\n");puts("\t\t\t\t1)增加人员信息\n"); puts("\t\t\t\t2)删除人员信息 \n"); puts("\t\t\t\t3)查询人员信息\n"); puts("\t\t\t\t4)修改人员信息\n"); puts("\t\t\t\t5)统计人员信息\n"); puts("\t\t\t\t6)对人员排序\n");puts("\t\t\t\t7)保存人员信息\n"); puts("\t\t\t\t8)浏览人员信息\n"); puts("\t\t\t\t9)退出\n");printf("\t\t\t\t 请选择 [ ]\b\b"); w0=getchar();}while(w0<'1'||w0>'9'); switch(w0-48){case 1:add();break;case 2:delete_data();break;case 3:search();break;case 4:modify();break; case 5:stastic();break;case 6:sort();break;case 7:save();break;case 8:browse();break;case 9:break;} }(1)查询功能int search_data()/*{int i,flag; char s[30],w0;system("cls");/*清屏*/ n=load(); do{fflush(stdin); /*清除缓冲区输入*/printf(" 通过1)编号 2)姓名 [ ]\b\b"); w0=getchar(); }while(w0<'1'||w0>'2'); if(w0=='1'){/*按编号查找*/ flag=0;puts("输入人员编号:"); scanf("%s",s); for(i=0;i<n;i++){if(strcmp(s,staff[i].num)==0){printf_face();printf_one(staff[i]); flag=1;break;} else continue; }if(flag==0)puts("该人员不存在!"); }else {/*按姓名查找*/ flag=0;puts("输入人员姓名:"); scanf("%s",s); for(i=0;i<n;i++){if(strcmp(s,staff[i].name)==0){printf_face();printf_one(staff[i]);flag=1;break;}else continue;}if(flag==0) puts("该人员不存在!");}return i;void search(){int k;char w1;loop: k=search_data();do{fflush(stdin); /*清除缓冲区输入*/printf("1)回主菜单 2)退出 3)继续查询 [ ]\b\b"); w1=getchar();}while(w1<'1'||w1>'3');if(w1=='1')menu();else if(w1=='2')exit(0);void add(){char w0,w1;loop: system("cls");puts("请输入编号(如001):");scanf("%s",s.num);if(test(s.num))goto loop;/*编号重复*/puts("请输入姓名:");scanf("%s",);puts("请输入性别(男,女):");scanf("%s",s.sex);puts("请输入年龄:");scanf("%d",&s.age);puts("请输入职务(教授副教授讲师助教学生后勤人员):");scanf("%s",s.duty);puts("请输入职称 (无初级高级 ):");scanf("%s",s.title);puts("请输入政治面貌( 党员非党员 ):");scanf("%s",s.p_landscape);puts("请输入最高学历(小学初中高中大学硕士学位更高):");scanf("%s",s.Qualifications);puts("请输入任职时间:");scanf("%d",&s.Service_time);puts("请输入来院时间(如20050101):");scanf("%s",e_time);puts("请输入人员类别(行政人员教师一般员工退休人员临时工):");scanf("%s",s.category);do{fflush(stdin); /*清除缓冲区输入*/printf("是否保存?1)是 2)否 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'2');switch(w0){case 1:save(s);break;case 2:break;}do{fflush(stdin); /*清除缓冲区输入*/printf("1)继续增加人员信息 2)回主菜单 3)退出 [ ]\b\b");w1=getchar();}while(w1<'1'||w1>'3');if(w1=='1')goto loop;else if(w1=='2')menu();else exit(0);}(3)保存信息void save(){char w0;save_all();printf("所有信息已保存!\n");do{fflush(stdin); /*清除缓冲区输入*/printf("1) 回主菜单 2) 退出 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'2');if(w0=='1')menu();else exit(0);}void save_all()/*保存所有数据函数*/{int i;FILE *fp;if((fp=fopen("text.txt","wb"))==NULL){printf("无法打开文件!");exit(0);}for(i=0;i<n;i++){if(staff[i].age!=0)fprintf(fp,"%s %s %s %d %s %s %s %s %d %s %s\n",staff[i].num,staff[i].name, staff[i].sex,staff[i].age,staff[i].duty,staff[i].title,staff[i].p_landscape,sta ff[i].Qualifications,staff[i].Service_time,staff[i].come_time,staff[i].category );else continue;}fclose(fp);}(4)删除人员void delete_data(){int k; char w0,w1;loop: k=search_data();if(k<n){do{fflush(stdin); /*清除缓冲区输入*/printf("确认要删除该人员信息? 1)是 2)否 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'2');if(w0=='1'){staff[k].age=0;save_all();puts("该人员信息已被删除!");} } do{fflush(stdin); /*清除缓冲区输入*/printf("1)继续删除数据 2)回主菜单 3)退出w1=getchar();}while(w1<'1'||w1>'3'); if(w1=='1') goto loop; else if(w1=='2')menu(); else exit(0); }(5)修改人员信息 void modify() {int k=0,w0,g; char h[30],w1,w2; loop: g=search_data(); if(g<n){ do{puts("\t\t\t 修改: 1)编号"); puts("\t\t\t 2)姓名"); puts("\t\t\t 3)性别"); puts("\t\t\t 4)年龄"); puts("\t\t\t 5)职务"); puts("\t\t\t 6)职称"); puts("\t\t\t 7)政治面貌"); puts("\t\t\t 8)最高学历"); puts("\t\t\t 9)任职时间"); puts("\t\t\t 10)来院时间"); puts("\t\t\t 11)人员类别"); printf(" 请选择 : [ ]\b\b"); scanf("%d",&w0);}while(w0<1||w0>11); switch(w0){case 1:puts("请输入新编号:");scanf("%s",h);strcpy(staff[g].num,h);break; case 2:puts("请输入姓名:");scanf("%s",h);strcpy(staff[g].name,h);break; case 3:puts("请输入性别:");scanf("%s",h);strcpy(staff[g].sex,h);break; case 4:puts("请输入年龄:");scanf("%d",&k);staff[g].age=k;break; case 5:puts("请输入职务:");scanf("%s",h);strcpy(staff[g].duty,h);break; case 6:puts("请输入职称:");scanf("%s",h);strcpy(staff[g].title,h);break;scanf("%s",h);strcpy(staff[g].p_landscape,h);break;case 8:puts("请输入最高学历:");scanf("%s",h);strcpy(staff[g].Qualifications,h);break;case 9:puts("请输入任职时间:");scanf("%d",&k);staff[g].Service_time=k;break;case 10:puts("请输入来院时间:");scanf("%s",h);strcpy(staff[g].come_time,h);break;case 11:puts("请输入人员类别:");scanf("%s",h);strcpy(staff[g].category,h);break;}do{fflush(stdin); /*清除缓冲区输入*/printf("是否保存?1)保存 2)否[ ]\b\b");w1=getchar();}while(w1<'1'||w1>'2');if(w1=='1'){save_all(); puts("保存修改成功!");}}do{fflush(stdin); /*清除缓冲区输入*/printf("1)继续修改 2)回主菜单 3)退出[ ]\b\b");w2=getchar();}while(w2<'1'||w2>'3');if(w2=='1')goto loop;else if(w2=='2')menu();else exit(0);}(6)统计人员信息void stastic(){int i,count;char w0,w1;n=load();if(n==0){puts("没有数据!");getchar();menu();}loop: system("cls");do{fflush(stdin); /*清除缓冲区输入*/printf("通过1)在职人员 2)党员\n");printf(" 3)女工人数 4)最高学历 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'4');if(w0=='1'){/*统计在职人员*/printf_face();for(i=0,count=0;i<n&&staff[i].age;i++)if(strcmp(staff[i].category,"退休人员")!=0&&strcmp(staff[i].category,"临时工")!=0){count++; printf_one(staff[i]);} printf("\t\t\t\t 共有%d 条记录",count); }else if(w0=='2'){/*统计党员*/ printf_face();for(i=0,count=0;i<n;i++)if(strcmp(staff[i].p_landscape,"党员count++; printf_one(staff[i]);} printf("\t\t\t\t 共有%d 条记录",count);}else if(w0=='3'){/*统计女工人员*/ printf_face();for(i=0,count=0;i<n;i++)if(strcmp(staff[i].sex,"女")==0){count++; printf_one(staff[i]);}printf("\t\t\t\t 共有%d 条记录",count);}else {/*统计高学历人员*/printf_face();for(i=0,count=0;i<n;i++)if(strcmp(staff[i].Qualifications,"硕士学位")==0||strcmp(staff[i].Qualifications,"更高")==0){count++; printf_one(staff[i]);} printf("\t\t\t\t 共有%d 条记录",count);} do{fflush(stdin); /*清除缓冲区输入*/printf("\n1)继续统计 2)回主菜单 3)退出 [ ]\b\b"); w1=getchar();}while(w1<'1'||w1>'3'); if(w1=='1') goto loop; else if(w1=='2')menu(); else exit(0); }(6) 排序功能void sort() {int i,j;char w0,w1; struct staff s1; loop: n=load();system("cls"); do{fflush(stdin); /*清除缓冲区输入*/printf("通过 1)年龄 2)来院时间w0=getchar();}while(w0<'1'||w0>'2');if(w0=='1'){/*按年龄排序*/for(i=0;i<n-1;i++)/*选择法排序*/for(j=i+1;j<n;j++)if(staff[i].age>staff[j].age){s1=staff[i];staff[i]=staff[j];staff[j]=s1;}}else {/*按来院时间排序*/for(i=0;i<n-1;i++)/*选择法排序*/for(j=i+1;j<n;j++)if(strcmp(staff[i].come_time,staff[j].come_time)>0){s1=staff[i];staff[i]=staff[j];staff[j]=s1;}}printf_face();for(i=0;i<n;i++) /*显示排序结果*/printf_one(staff[i]);do{fflush(stdin); /*清除缓冲区输入*/printf("\n1)回主菜单 2)继续排序 3)退出[ ]\b\b");w1=getchar();}while(w1<'1'||w1>'3');if(w1=='1') menu();else if(w1=='2')goto loop;else exit(0);}四、运行与测试报告*********************************高校人事管理系统******************************1)增加人员信息2)删除人员信息3)查询人员信息4)修改人员信息5)统计人员信息6)对人员排序7)保存人员信息8)浏览人员信息9)退出请选择【 1】请输入编号(如001):20071003335请输入姓名:majianbo请输入性别(男,女):nan请输入年龄:20请输入职务(教授副教授讲师助教学生后勤人员): jiaoshou请输入职称 (无初级高级 ):gaoji请输入政治面貌( 党员非党员 ):danyuan请输入最高学历(小学初中高中大学硕士学位更高): shuoshi请输入任职时间:20070901请输入来院时间(如20050101):20070901请输入人员类别(行政人员教师一般员工退休人员临时工): jiaoshi是否保存?1)是 2)否 [1]该信息已成功保存!1)继续增加人员信息 2)回主菜单 3)退出 [ ]程序:#include<stdlib.h>#include <stdio.h>#include <string.h>struct staff/*定义结构体*/{char num[10];/*编号*/char name[20];/*姓名*/char sex[10];/*性别*/int age;/*年龄*/char duty[20];/*职务*/char title[20];/*职称*/char p_landscape[30];/*政治面貌*/char Qualifications[30];/*学历*/int Service_time;/*任职时间*/char come_time[30];/*来院时间*/char category[30];/*人员类别*/}staff[100];struct staff s;int n;void menu();void printf_face()/*显示数据结构项目函数*/{printf("编号姓名性别年龄职务职称政治面貌学历任职时间来院时间人员类别\n");}void printf_one(struct staff p)/*输出单个数据函数*/{printf("%-4s%-7s%-5s%-3d%-7s%-5s%-8s%-12s%-5d%-12s%-3s\n",p.num,,p.se x,p.age,p.duty,p.title,p.p_landscape,p.Qualifications,p.Service_time,e_tim e,p.category);}int load()/*加载函数*/{int i=0;FILE *fp;if((fp=fopen("text.txt","rb"))==NULL){return 0; exit(0);}for(i=0;!feof(fp);i++){ /*输出数据到结构体*/fscanf(fp,"%s %s %s %d %s %s %s %s %d %s %s\n",staff[i].num,staff[i].name,staff [i].sex,&staff[i].age,staff[i].duty,staff[i].title,staff[i].p_landscape,staff[i ].Qualifications,&staff[i].Service_time,staff[i].come_time,staff[i].category);} fclose(fp);return i;}int search_data()/*查找单个数据函数*/{int i,flag;char s[30],w0;system("cls");/*清屏*/n=load();do{fflush(stdin); /*清除缓冲区输入*/printf(" 通过1)编号 2)姓名 [ ]\b\b");w0=getchar(); }while(w0<'1'||w0>'2');if(w0=='1'){/*按编号查找*/flag=0;puts("输入人员编号:");scanf("%s",s);for(i=0;i<n;i++){if(strcmp(s,staff[i].num)==0){printf_face();printf_one(staff[i]);flag=1;break;}else continue;}if(flag==0)puts("该人员不存在!");}else {/*按姓名查找*/flag=0;puts("输入人员姓名:");scanf("%s",s);for(i=0;i<n;i++){if(strcmp(s,staff[i].name)==0){printf_face();printf_one(staff[i]);flag=1;break;}else continue;}if(flag==0) puts("该人员不存在!");}return i;}void save_all()/*保存所有数据函数*/{int i;FILE *fp;if((fp=fopen("text.txt","wb"))==NULL){printf("无法打开文件!");exit(0);}for(i=0;i<n;i++){if(staff[i].age!=0)fprintf(fp,"%s %s %s %d %s %s %s %s %d %s %s\n",staff[i].num,staff[i].name, staff[i].sex,staff[i].age,staff[i].duty,staff[i].title,staff[i].p_landscape,sta ff[i].Qualifications,staff[i].Service_time,staff[i].come_time,staff[i].category );else continue;}fclose(fp);}int test(char h[10])/*检查编号是否重复*/{int i;n=load();for(i=0;i<n;i++)if(strcmp(h,staff[i].num)==0){puts("输入的编号有重复!请重新输入编号!");system("pause");return 1;}return 0;}void single_save(struct staff p)/*保存单个数据函数*/{FILE *fp;if((fp=fopen("text.txt","ab+"))==NULL){printf("无法打开文件!");exit(0);}fprintf(fp,"%s %s %s %d %s %s %s %s %d %s %s\n",p.num,,p.sex,p.age,p.duty ,p.title,p.p_landscape,p.Qualifications,p.Service_time,e_time,p.category);printf("该信息已成功保存!\n");fclose(fp);}/*********************************修改模块**********************************/ void modify(){int k=0,w0,g;char h[30],w1,w2;loop: g=search_data();if(g<n){do{puts("\t\t\t修改: 1)编号");puts("\t\t\t 2)姓名");puts("\t\t\t 3)性别");puts("\t\t\t 4)年龄");puts("\t\t\t 5)职务");puts("\t\t\t 6)职称");puts("\t\t\t 7)政治面貌");puts("\t\t\t 8)最高学历");puts("\t\t\t 9)任职时间");puts("\t\t\t 10)来院时间");puts("\t\t\t 11)人员类别");printf(" 请选择 : [ ]\b\b");scanf("%d",&w0);}while(w0<1||w0>11);switch(w0){case 1:puts("请输入新编号:");scanf("%s",h);strcpy(staff[g].num,h);break;case 2:puts("请输入姓名:");scanf("%s",h);strcpy(staff[g].name,h);break;case 3:puts("请输入性别:");scanf("%s",h);strcpy(staff[g].sex,h);break;case 4:puts("请输入年龄:");scanf("%d",&k);staff[g].age=k;break;case 5:puts("请输入职务:");scanf("%s",h);strcpy(staff[g].duty,h);break;case 6:puts("请输入职称:");scanf("%s",h);strcpy(staff[g].title,h);break;case 7:puts("请输入政治面貌:");scanf("%s",h);strcpy(staff[g].p_landscape,h);break;case 8:puts("请输入最高学历:");scanf("%s",h);strcpy(staff[g].Qualifications,h);break;case 9:puts("请输入任职时间:");scanf("%d",&k);staff[g].Service_time=k;break;case 10:puts("请输入来院时间:");scanf("%s",h);strcpy(staff[g].come_time,h);break;case 11:puts("请输入人员类别:");scanf("%s",h);strcpy(staff[g].category,h);break;}do{fflush(stdin); /*清除缓冲区输入*/printf("是否保存?1)保存 2)否[ ]\b\b");w1=getchar();}while(w1<'1'||w1>'2');if(w1=='1'){save_all(); puts("保存修改成功!");}}do{fflush(stdin); /*清除缓冲区输入*/printf("1)继续修改 2)回主菜单 3)退出[ ]\b\b");w2=getchar();}while(w2<'1'||w2>'3');if(w2=='1')goto loop;else if(w2=='2')menu();else exit(0);}/************************保存模块******************************/void save(){char w0;save_all();printf("所有信息已保存!\n");do{fflush(stdin); /*清除缓冲区输入*/printf("1) 回主菜单 2) 退出 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'2');if(w0=='1')menu();else exit(0);}/*************************查找模块*****************************/ void search(){int k;char w1;loop: k=search_data();do{fflush(stdin); /*清除缓冲区输入*/printf("1)回主菜单 2)退出 3)继续查询 [ ]\b\b");w1=getchar();}while(w1<'1'||w1>'3');if(w1=='1')menu();else if(w1=='2')exit(0);else goto loop;}/***************************增加模块*****************************/ void add(){char w0,w1;loop: system("cls");puts("请输入编号(如001):");scanf("%s",s.num);if(test(s.num))goto loop;/*编号重复*/puts("请输入姓名:");scanf("%s",);puts("请输入性别(男,女):");scanf("%s",s.sex);puts("请输入年龄:");scanf("%d",&s.age);puts("请输入职务(教授副教授讲师助教学生后勤人员):");scanf("%s",s.duty);puts("请输入职称 (无初级高级 ):");scanf("%s",s.title);puts("请输入政治面貌( 党员非党员 ):");scanf("%s",s.p_landscape);puts("请输入最高学历(小学初中高中大学硕士学位更高):");scanf("%s",s.Qualifications);puts("请输入任职时间:");scanf("%d",&s.Service_time);puts("请输入来院时间(如20050101):");scanf("%s",e_time);puts("请输入人员类别(行政人员教师一般员工退休人员临时工):");scanf("%s",s.category);do{fflush(stdin); /*清除缓冲区输入*/printf("是否保存?1)是 2)否 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'2');switch(w0-48){case 1:single_save(s);break;case 2:break;}do{fflush(stdin); /*清除缓冲区输入*/printf("1)继续增加人员信息 2)回主菜单 3)退出 [ ]\b\b");w1=getchar();}while(w1<'1'||w1>'3');if(w1=='1')goto loop;else if(w1=='2')menu();else exit(0);}/*******************************删除模块*****************************/void delete_data(){int k; char w0,w1;loop: k=search_data();if(k<n){do{fflush(stdin); /*清除缓冲区输入*/printf("确认要删除该人员信息? 1)是 2)否 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'2');if(w0=='1'){staff[k].age=0;save_all();puts("该人员信息已被删除!");}}do{fflush(stdin); /*清除缓冲区输入*/printf("1)继续删除数据 2)回主菜单 3)退出 [ ]\b\b");w1=getchar();}while(w1<'1'||w1>'3');if(w1=='1') goto loop;else if(w1=='2')menu();else exit(0);}/********************************统计模块*******************************/void stastic(){int i,count;char w0,w1;n=load();if(n==0){puts("没有数据!");getchar();menu();}loop: system("cls");do{fflush(stdin); /*清除缓冲区输入*/printf("通过1)在职人员 2)党员\n");printf(" 3)女工人数 4)最高学历 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'4');if(w0=='1'){/*统计在职人员*/printf_face();for(i=0,count=0;i<n&&staff[i].age;i++)if(strcmp(staff[i].category,"退休人员")!=0&&strcmp(staff[i].category,"临时工")!=0){count++; printf_one(staff[i]);}printf("\t\t\t\t共有%d条记录",count);}else if(w0=='2'){/*统计党员*/printf_face();for(i=0,count=0;i<n;i++)if(strcmp(staff[i].p_landscape,"党员")==0){count++; printf_one(staff[i]);}printf("\t\t\t\t共有%d条记录",count);}else if(w0=='3'){/*统计女工人员*/printf_face();for(i=0,count=0;i<n;i++)if(strcmp(staff[i].sex,"女")==0){count++; printf_one(staff[i]);}printf("\t\t\t\t共有%d条记录",count);}else {/*统计高学历人员*/printf_face();for(i=0,count=0;i<n;i++)if(strcmp(staff[i].Qualifications,"硕士学位")==0||strcmp(staff[i].Qualifications,"更高")==0){count++; printf_one(staff[i]);}printf("\t\t\t\t共有%d条记录",count);}do{fflush(stdin); /*清除缓冲区输入*/printf("\n1)继续统计 2)回主菜单 3)退出 [ ]\b\b");w1=getchar();}while(w1<'1'||w1>'3');if(w1=='1') goto loop;else if(w1=='2')menu();else exit(0);}/*******************************排序模块***********************************/ void sort(){int i,j;char w0,w1;struct staff s1;loop: n=load();system("cls");do{fflush(stdin); /*清除缓冲区输入*/printf("通过 1)年龄 2)来院时间 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'2');if(w0=='1'){/*按年龄排序*/for(i=0;i<n-1;i++)/*选择法排序*/for(j=i+1;j<n;j++)if(staff[i].age>staff[j].age){s1=staff[i];staff[i]=staff[j];staff[j]=s1;}}else {/*按来院时间排序*/for(i=0;i<n-1;i++)/*选择法排序*/for(j=i+1;j<n;j++)if(strcmp(staff[i].come_time,staff[j].come_time)>0){s1=staff[i];staff[i]=staff[j];staff[j]=s1;}}printf_face();for(i=0;i<n;i++) /*显示排序结果*/printf_one(staff[i]);do{fflush(stdin); /*清除缓冲区输入*/printf("\n1)回主菜单 2)继续排序 3)退出[ ]\b\b");w1=getchar();}while(w1<'1'||w1>'3');if(w1=='1') menu();else if(w1=='2')goto loop;else exit(0);}/********************************浏览模块**************************************/void browse(){int i;char w0;n=load();system("cls");printf_face();for(i=0;i<n ;i++)printf_one(staff[i]);printf("\t\t\t\t共有%d条人员记录\n",n);do{fflush(stdin); /*清除缓冲区输入*/printf(" 1)回主菜单 2)退出 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'2');if(w0=='1') menu();if(w0=='2') exit(0);}/********************************主菜单函数*************************************/void menu(){char w0;do{system("cls");fflush(stdin); /*清除缓冲区输入*/puts("*********************************高校人事管理系统*******************************\n\n");puts("\t\t\t\t1)增加人员信息\n");puts("\t\t\t\t2)删除人员信息 \n");puts("\t\t\t\t3)查询人员信息\n");puts("\t\t\t\t4)修改人员信息\n");puts("\t\t\t\t5)统计人员信息\n");puts("\t\t\t\t6)对人员排序\n");puts("\t\t\t\t7)保存人员信息\n");puts("\t\t\t\t8)浏览人员信息\n");puts("\t\t\t\t9)退出\n");printf("\t\t\t\t请选择 [ ]\b\b");w0=getchar();}while(w0<'1'||w0>'9');switch(w0-48){case 1:add();break;case 2:delete_data();break;case 3:search();break;case 4:modify();break;case 5:stastic();break;case 6:sort();break;case 7:save();break;case 8:browse();break;case 9:break;}}/***********************************主函数****************************************/void main(){menu();}。
文件管理系统一、实验目的通过设计一个多用户文件系统, 了解操作系统中文件的组织与管理, 熟悉文件管理所用 的数据结构,加深对文件系统内部功能实现过程的理解。
二、实验内容1.用 C 语言或 C++ 语言设计一个最多包括 N 个用户的多用户文件系统, 约定每个用户 最多保存 M 个文件。
同时限制一个用户在进入系统后,最多打开 L 个文件。
2.系统应具备一定的健壮性。
即能够检查用户所输入命令的正确性,出错时显示出必 要的信息。
另外,对文件需设置必要的保护措施。
3.文件目录结构采用两级目录结构 : 主文件目录和用户文件目录#include"io.h" #include"conio.h" #include"stdio.h" #include"stdlib.h"#include"malloc.h" #include"string.h" #include"ctype.h" #define N 30 #define M 20 #define L 5 typedef struct MFD {char username[100];char password[100];FILE fp;/*文件指针 */}MFD;/////////// typedef struct UFD /* 用户文件目录 */ { char filename[256];char protect; /* 保护码 */int length; /* 文件长度 */ }UFD;////////// typedef struct OFD{charfilename[256]; char opencode; /* 打开保护码 */ int fp; /* 读写指针 */}OFD;/* 用户数 *//* 一个用户可保存 M 个文件*/ /*用户只能一次打开 L 个文件 */ /* 主文件目录 */ /* 打开文件目录 */////////// typedef struct COMM /* 命令串 */{char string[256]; /* 命令 */struct COMM *next;/* 后继指针 */ }COMM;////////////MFD mainfd[N];UFD userfd[M];OFD openfd[L];////////COMM*command; charusername[10];int usernum,savenum,opennum; int workfile;void init();void init_ufd(char*username);/* voidmesg(char *str);char *getpass();char *getuser();COMM *readcommand();void login();void logout();void setpass();void create();void mydelete();void myread();void myopen();void myclose();void mywrite();void help();void dir();void mycopy();void myrename();/////////////初始化用户文件目录 */ /*消息 */ /* 设置口令函数声明 */ /* 设置用户函数声明 */ /* 读命令串函数声明 */ /* 用户登录 */ /* 用户注销 */ /* 设置口令 */ /* 创建文件 */ /* 删除文件 */ /* 读文件 */ /* 打开文件 */ /* 关闭文件 */ /* 写文件 */ /*帮助 */ /* 列文件目录 */ /* 复制文件 */ /* 重命名文件名 */void main(){init();for(;;)readcommand();if(strcmp(command->string,"create")==0)create();else if(strcmp(command->string,"delete")==0)/* 主文件目录数组 */ /* 用户文件目录数组 */ /* 打开文件目录数组 */mydelete();else if(strcmp(command->string,"open")==0)myopen();else if(strcmp(command->string,"close")==0)myclose();else if(strcmp(command->string,"read")==0)myread();else if(strcmp(command->string,"write")==0)mywrite();else if(strcmp(command->string,"copy")==0)mycopy();else if(strcmp(command->string,"rename")==0)myrename();else if(strcmp(command->string,"login")==0)login();else if(strcmp(command->string,"setpass")==0)setpass();else if(strcmp(command->string,"logout")==0)logout();else if(strcmp(command->string,"help")==0)help();else if(strcmp(command->string,"dir")==0) dir();else if(strcmp(command->string,"exit")==0)break;elsemesg("Bad command!");}}///////////////////void init(){FILE *fp;char tempname[20],temppass[20];int i=0;usernum=0;savenum=0;opennum=0;strcpy(username,"");if((fp=fopen("mainfile.txt","r"))!=NULL) {while(!feof(fp))strcpy(tempname,"");fgets(tempname,20,fp);if(strcmp(tempname,"")!=0){{fgets(temppass,20,fp);tempname[strlen(tempname)-1]='\0';temppass[strlen(tempname)-1]='\0';strcpy(mainfd[usernum].username,tempname);strcpy(mainfd[usernum].password,tempname); usernum++;}}fclose(fp);}}///////////////////////void init_ufd(char *username)/* 初始化用户文件目录*/ {FILE *fp;char tempfile[100],tempprot;int templength;savenum=0;opennum=0;workfile=-1;if((fp=fopen(username,"w+"))!=NULL){while(!feof(fp)){strcpy(tempfile,"");fgets(tempfile,50,fp);if(strcmp(tempfile,"")!=0){fscanf(fp,"%c",&tempprot);fscanf(fp,"%d",&templength);tempfile[strlen(tempfile)-1]='\0';strcpy(userfd[savenum].filename,tempfile); userfd[savenum].protect=tempprot;userfd[savenum].length=templength;savenum++;fgets(tempfile,50,fp);}fclose(fp);}////////////////////void mesg(char *str){printf("\n %s\n",str);}////////////////////////////char *getuser(){char username[20];char temp;int i;username[0]='\0';for(i=0;i<10;){while(!kbhit());temp=getch();if(isalnum(temp)||temp=='_'||temp==13) {username[i]=temp; if(username[i]==13){username[i]='\0'; break;}putchar(temp);i++;username[i]='\0';}}return(username);}///////////////////char *getpass(){char password[20];char temp;int i;password[0]='\0';for(i=0;i<10;)while(!kbhit());temp=getch();{if(isalnum(temp)||temp=='_'||temp==13){password[i]=temp;if(password[i]==13){password[i]='\0';break;}putchar('*');i++;password[i]='\0';}}return(password);}///////////////COMM *readcommand(){char temp[256];char line[256];int i,end;COMM *newp,*p;command=NULL;strcpy(line,""); while(strcmp(line,"")==0){printf("\nc:\\>");gets(line);}for(i=0;i<=strlen(line);i++){if(line[i]==' ')i++;end=0;while(line[i]!='\0'&&line[i]!=' '){temp[end]=line[i];end++;i++;}if(end>0)temp[end]='\0';newp=(COMM *)malloc(sizeof(COMM *));{strcpy(newp->string,temp);newp->next=NULL;if(command==NULL) command=newp;else{p=command;while(p->next!=NULL) p=p->next;p->next=newp;}}} p=command;return(command);}/////////////////////////////void login() /* 用户注册*/{FILE *fp;int i;char password[20],confirm[20],tempname[20]; if(command->next==NULL){printf("\n User Name:"); strcpy(tempname,getuser());}else if(command->next->next!=NULL){mesg("Too many parameters!");return;}else strcpy(tempname,command->next->string);for(i=0;i<usernum;i++) if(strcmp(mainfd[i].username,tempname)==0)break; /* 从mainfd 表中查找要注册的用户*/ if(i>=usernum) /* 新用户*/{printf("\n new user account,enter your password twice!"); printf("\nPassword:");strcpy(password,getpass());/* 输入口令且返回之*/ printf("\nPassword:");strcpy(confirm,getpass()); /* 第二次输入口令*/if(strcmp(password,confirm)==0)/* 用户数不能超过N*/ {if(usernum>=N)mesg("Create new account false!number of user asscount limited.\n login fasle!");else{strcpy(mainfd[usernum].username,tempname);/* 把新用户和口令填入mainfd 中*/strcpy(mainfd[usernum].password,password); usernum++;strcpy(username,tempname);mesg("Create a new user!\n login success!");init_ufd(username); /* 初始化用户文件目录*/fp=fopen("mainfile.txt","w+"); /* 把新用户填入mainfile.txt 文件中*/for(i=0;i<usernum;i++){fputs(mainfd[i].username,fp); fputs("\n",fp);fputs(mainfd[i].password,fp);fputs("\n",fp);}fclose(fp);}}else{mesg("Create new account false! Error password.");mesg("login false!");}}else{printf("\n Password:"); strcpy(password,getpass());if(strcmp(mainfd[i].password,password)!=0)mesg("Login false! Error password.");else{mesg("Login success!");strcpy(username,tempname);init_ufd(username);}}}/////////////////////////void logout() /* 用户注销*/{ if(command->next!=NULL)mesg("Too many parameters!");else if(strcmp(username,"")==0)mesg("No user login!");else { strcpy(username,""); opennum=0; savenum=0; workfile=-1; mesg("Userlogout!");}}////////////////////void setpass() /* 修改口令*/{int i=0;FILE *fp;char oldpass[20],newpass[20],confirm[20]; if(strcmp(username,"")==0) mesg("No user login!");else {printf("\n Old password:"); strcpy(oldpass,getpass()); for(inti=0;i<usernum;i++) {if(strcmp(mainfd[i].username,username)==0) break;} if(strcmp(mainfd[i].password,oldpass)!=0) mesg("Old password error!");else{printf("\n New password:"); strcpy(newpass,getpass()); printf("\nConfirm password:");文件管理系统源代码{strcpy(confirm,getpass()); if(strcmp(newpass,confirm)!=0) mesg("Password not change! confirm different.");else{ strcpy(mainfd[i].password,newpass); mesg(" Password change !");fp=fopen("mainfile.txt","w+"); for(i=0;i<usernum;i++) {fputs(mainfd[i].username,fp); fputs("\n",fp);fputs(mainfd[i].password,fp);fputs("\n",fp);}fclose(fp);}}}}////////////////void create(){int i=0;FILE *fp;if(strcmp(username,"")==0)mesg("No user lgoin!");else if(command->next==NULL) mesg("Too few parametets!");else if(command->next->next!=NULL)mesg("Too many parameters!");else{for(i=0;i<savenum;i++){if(strcmp(userfd[i].filename,command->next->string)==0) break;}if(i<savenum)mesg("Error! the file already existed!");else if(savenum>=M)mesg("Error! connot create file! number of files limited!"); elsestrcpy(userfd[savenum].filename,command->next->string);userfd[i].protect='r';userfd[i].length=rand();savenum++; mesg("Create file success!"); fp=fopen(username,"w+");for(i=0;i<savenum;i++){ fputs(userfd[i].filename,fp); fputs("\n",fp);fprintf(fp,"%c\n%d\n",userfd[i].protect,userfd[i].length);} fclose(fp);}}}/////////////////void mydelete() /* 删除*/{int i=0;int tempsave=0;FILE *fp; if(strcmp(username,"")==0) mesg("No user lgoin!");else if(command->next==NULL)mesg("Too few parametets!");else if(command->next->next!=NULL) mesg("Too many parameters!");else { for(i=0;i<savenum;i++) {if(strcmp(userfd[i].filename,command->next->string)==0) break;}if(i>=savenum)mesg("Error! the file not existed!"); else{ tempsave=i; for(i=0;i<opennum;i++) {if(strcmp(command->next->string,openfd[i].filename)==0) break;} if(i>=opennum) mesg("File not open");////////////////////////////////////////////else{ if(tempsave==savenum-1) savenum--;else{ for(;tempsave<savenum-1;tempsave++){ strcpy(userfd[tempsave].filename,userfd[tempsave+1].filename);userfd[tempsave].protect=userfd[tempsave+1].protect;userfd[tempsave].length=userfd[tempsave+1].length;}savenum--;} mesg("Delete file success!"); fp=fopen(username,"w+");for(i=0;i<savenum;i++){ fputs(userfd[i].filename,fp); fputs("\n",fp);fprintf(fp,"%c\n%d\n",userfd[i].protect,userfd[i].length);} fclose(fp);}}}}//////////////////void myread() /*读*/{int i=0;int tempsave=0;char tempfile[100]; if(strcmp(username,"")==0) mesg("No user lgoin!");else if(command->next==NULL)mesg("Too few parametets!");else if(command->next->next!=NULL)mesg("Too many parameters!");else{strcpy(tempfile,command->next->string); for(i=0;i<savenum;i++){ if(strcmp(tempfile,userfd[i].filename)==0) break;} if(i>=savenum) mesg("File not existed!");else{tempsave=i;for(i=0;i<opennum;i++){ if(strcmp(tempfile,openfd[i].filename)==0) break;} if(i>=opennum) mesg("File not opened");else{ if(userfd[tempsave].length<1000) printf("\n The file size is %dKB",userfd[tempsave].length);else if(userfd[tempsave].length==1000) printf("\n The file size is1000 KB");elseprintf("\n The file size is%d,%d KB",userfd[tempsave].length/1000,userfd[tempsave].length%1000);mesg("File read");}}}}/////////////////void myopen()/* 打开*/{int i=0;int type=0;char tempcode;char tempfile[100];if(strcmp(username,"")==0)mesg("No user login!");else if(command->next==NULL)mesg("Too few parameters!");else{strcpy(tempfile,"");文件管理系统源代码tempcode='r';if(strcmp(command->next->string,"/r")==0){tempcode='r';type=1;}else if(strcmp(command->next->string,"/w")==0){tempcode='w';type=1;}else if(strcmp(command->next->string,"/d")==0){tempcode='d';type=1;}else if(command->next->string[0]=='/')mesg("Error! /r/w/d request!");else if(command->next->next!=NULL)mesg("Too many parameters!");elsestrcpy(tempfile,command->next->string);if(type==1){if(command->next->next!=NULL){if(command->next->next->next!=NULL) mesg("Too many parameters!");else strcpy(tempfile,command->next->next->string);}elsemesg("Too few parameters!");}if(strcmp(tempfile,"")){for(i=0;i<savenum;i++){if(strcmp(tempfile,userfd[i].filename)==0) break;if(i>=savenum)mesg("File not existed!");else{for(i=0;i<opennum;i++){if(strcmp(tempfile,openfd[i].filename)==0)break;}if(i<opennum){mesg("File already opened!");if(openfd[i].opencode!=tempcode){openfd[i].opencode=tempcode;mesg("File permission changed!");}}else if(opennum>=L){mesg("Error! connot open file! number of opened fileslimited!");}else{ strcpy(openfd[opennum].filename,tempfile);openfd[opennum].opencode=tempcode; workfile=opennum;opennum++;mesg("File open success!");}}}}}///////////////////////void myclose()/* 关闭*/{int i=0;int tempsave=0;char tempfile[100];if(strcmp(username,"")==0)mesg("No user lgoin!");else if(command->next==NULL)mesg("Too few parametets!");else if(command->next->next!=NULL)mesg("Too many parameters!");else{ strcpy(tempfile,command->next->string); for(i=0;i<savenum;i++){ if(strcmp(tempfile,userfd[i].filename)==0) break;} if(i>=savenum) mesg("File not existed!");else{for(i=0;i<opennum;i++){ if(strcmp(tempfile,openfd[i].filename)==0) break;}if(i>=opennum) mesg("File not opened");else{if(i==opennum-1) opennum--;else{ for(;i<opennum-1;i++) {strcpy(openfd[i].filename,openfd[i+1].filename);openfd[i].opencode=openfd[i+1].opencode;} opennum--;} mesg("Close file success!");}}}}/////////////////////////void mywrite()/* 写*/{int i=0;文件管理系统源代码int tempsave=0;char tempfile[100]; if(strcmp(username,"")==0)mesg("No user lgoin!");else if(command->next==NULL) mesg("Too few parametets!");else if(command->next->next!=NULL) mesg("Too many parameters!");else{ strcpy(tempfile,command->next->string);for(i=0;i<savenum;i++){if(strcmp(tempfile,userfd[i].filename)==0)break;}if(i>=savenum) mesg("File not existed!");else{tempsave=i;for(i=0;i<opennum;i++){if(strcmp(tempfile,openfd[i].filename)==0)break;}if(i>=opennum) mesg("File not opened");else{mesg("File write");int tt=rand();if(userfd[tempsave].length<=1000)printf("\n The file size from %d KB to %dKB",userfd[tempsave].length,userfd[tempsave].length+tt);/* else if(userfd[tempsave].lenght=1000)printf("\n The file size from 1000 KB");*/ elseprintf("\n The file size form %d,%d KB to %d,%dKB",userfd[tempsave].length/1000,userfd[tempsave].length%1000,userfd[tempsave].lengt h+tt/10 00,userfd[tempsave].length+tt%1000);userfd[tempsave].length=userfd[tempsave].length+tt;}}}///////////////////void help()/* 帮助*/{static char *cmd[]={"login","setpass","logout","create","open","read","write","close","delete","dir","help","exit","copy","rename"};static char *cmdhlp[]={"aommand format: login [<username>]","command format:setpass","command format:logout","command format:create <filename>","command format:open [/r/w/d] <filename>","command format:read <filename>","command format:write <filename>","command format:close <filename>","command format:delete <filename>","command format:dir [/u/o/f]","command format:help [<command>]","command format:exit","command format:copy <source filename> <destination filename>","command format:rename <old filename> <new filename>"};static char *detail[]={"explain:user login in the file system.","explain:modify the user password.","explain:user logout the file system.","explain:creat a new file.","explain:/r -- read only [deflaut]\n\t /w -- listopened files \n\t/d --read,modify and delete.","explain:read the file.","explain:modify the file.","explain:close the file.","explain:delete the file.","explain:/u -- list the user account\n\t /0 -- listopened files\n\t/f --list user file[deflaut].","explain:<command> -- list the command detail format and explain.\n\t [deflaut] list the command.","explain:exit from the file sysytem.","explain:copy from one file to another file.","explain:modify the file name."};int helpnum=14;int i=0;if(command->next==NULL){mesg(cmdhlp[10]);mesg(detail[10]);mesg("step 1: login");printf("\t if old user then login,if user not exist then create new user");mesg("step 2: open the file for read(/r),write(/w)or delete(/d)");printf("\t you can open one or more files.one command can open one file");mesg("step 3: read,write or delete some one file");printf("\t you can operate one of the opened files.one command can open onefile"); mesg("step 4: close the open file");printf("\t you can close one of the opened files.one command can open onefile"); mesg("step 5: user logout.close all the user opened files");printf("\n command list:");for(i=0;i<helpnum;i++){if(i%4==0) printf("\n");printf(" %-10s",cmd[i]);}}else if(command->next->next!=NULL)mesg("Too many parameters!");else{for(i=0;i<helpnum;i++){ if(strcmp(command->next->string,cmd[i])==0) break;}if(i>=helpnum)mesg("the command not existed!");else{mesg(cmdhlp[i]); mesg(detail[i]);}}}//////////////////////void dir()/* 列目录文件*/{int i=0;int type=0;char tempcode;if(strcmp(username,"")==0)mesg("No user login!");else{if(command->next==NULL){tempcode='f';else{ if(strcmp(command->next->string,"/u")==0) {tempcode='u';}else if(strcmp(command->next->string,"/o")==0){tempcode='o';}else if(strcmp(command->next->string,"/f")==0){tempcode='f';}else if(command->next->string[0]=='/') mesg("Error! /u/o/f request!");elseif(command->next->next!=NULL)mesg("Too many parameters!");}if('u'==tempcode){printf("list the user account\n"); printf("usename\n");for(i=0;i<usernum;i++){ printf("%s\n",mainfd[i].username);}}else if('f'==tempcode){printf("list opened files\n"); printf("filename length protect\n");for(i=0;i<savenum;i++){ printf("%s%s%d%s%s%c\n",userfd[i].filename," ",userfd[i].length,"KB"," ",userfd[i].protect);}else if('o'==tempcode){printf("list user files\n");printf("filename opencode\n"); for(i=0;i<opennum;i++){ printf("%s%s%c\n",openfd[i].filename,"}",openfd[i].opencode);}}}/////////////////////////void mycopy()/* 复制*/{char sourfile[256],destfile[256];int i=0,j=0,temp=0;FILE *fp;char tempchar;if(strcmp(username,"")==0)mesg("No user lgoin!");else if(command->next==NULL)mesg("Too few parametets!");else if(command->next->next==NULL)mesg("Too few parametets!");else if(command->next->next->next!=NULL)mesg("Too many parameters!");else{strcpy(sourfile,command->next->string);strcpy(destfile,command->next->next->string); for(i=0;i<savenum;i++){if(strcmp(sourfile,userfd[i].filename)==0) break;}temp=i;if(i>=savenum)printf("\n the source file not eixsted!");else{ for(i=0;i<opennum;i++) {if(strcmp(sourfile,openfd[i].filename)==0) break;}if(i>=opennum)printf("\n the source file not opened!");else{for(j=0;j<opennum;j++){if(strcmp(destfile,openfd[i].filename)==0)break;}if(j<opennum)文件管理系统源代码mesg("Error! the destination file opened,you must close it first."); else{for(j=0;j<savenum;j++){if(strcmp(destfile,userfd[i].filename)==0)break;}if(j<savenum){mesg("Warning! the destination file exist!");printf("\n Are you sure to recover if ? [Y/N]");while(!kbhit());tempchar=getch();if(tempchar=='N'||tempchar=='n')mesg("Cancel! file not copy.");else if(tempchar=='Y'||tempchar=='y'){mesg("File copy success!file recovered!");userfd[j].length=userfd[i].length;userfd[j].protect=userfd[i].protect;fp=fopen(username,"w+");for(i=0;i<savenum;i++){fputs(userfd[i].filename,fp);fputs("\n",fp);fprintf(fp,"%C\n%d\n",userfd[i].protect,userfd[i].length);}fclose(fp);}}else if(savenum>=M)mesg("copy false! file total limited.");else{strcpy(userfd[savenum].filename,destfile);userfd[savenum].length=userfd[temp].length;userfd[savenum].protect=userfd[temp].protect;savenum++;fp=fopen(username,"w+");for(i=0;i<savenum;i++){fputs(userfd[i].filename,fp);fputs("\n",fp);fprintf(fp,"%c\n%d\n",userfd[i].protect,userfd[i].length);}fclose(fp);mesg("File copy success!");}}}}}}///////////////////////void myrename()/* 文件重命名*/{char oldfile[256],newfile[256];int i=0,temp=0;if(strcmp(username,"")==0)mesg("No user lgoin!");else if(command->next==NULL)mesg("Too few parametets!");else if(command->next->next==NULL)mesg("Too few parametets!");else if(command->next->next->next!=NULL)mesg("Too many parameters!");else{strcpy(oldfile,command->next->string);strcpy(newfile,command->next->next->string);for(i=0;i<savenum;i++){if(strcmp(oldfile,userfd[i].filename)==0)break;}} }temp=i;if(temp>=savenum)printf("\n the source file not eixsted!");else if(temp!=i&&i<savenum){printf("\n newfile and the existing files is the same name, please re-naming!"); } else{for(i=0;i<opennum;i++){if(strcmp(oldfile,openfd[i].filename)==0) break;}if(i>=opennum)printf("\n the source file not opened!");else if(strcmp(oldfile,newfile)==0){printf("Rename false! oldfile and newfile can not be the same.");}else{ strcpy(openfd[i].filename,newfile);strcpy(userfd[temp].filename,newfile); mesg("Rename filesuccess!\n");}。
C语言课程设计实验报告学生信息管理系统目录1. 内容综述 (2)1.1 实验背景 (2)1.2 实验目的 (3)1.3 实验内容 (4)2. 系统设计 (5)2.1 系统需求分析 (5)2.1.1 功能需求 (6)2.1.2 性能需求 (7)2.1.3 界面需求 (7)2.2 系统总体结构 (9)2.3 系统模块设计 (10)2.3.1 数据模块 (10)2.3.2 功能模块 (11)3. 系统实现 (12)3.1 开发环境 (13)3.1.1 编译器 (13)3.1.2 操作系统 (14)3.1.3 开发工具 (16)3.2 关键代码实现 (17)3.2.1 数据结构设计 (17)3.2.2 数据库操作 (18)3.2.3 功能实现 (19)3.3 系统测试 (20)3.3.1 功能测试 (22)3.3.2 性能测试 (22)3.3.3 界面测试 (23)4. 系统运行结果与分析 (25)4.2 功能测试结果 (27)4.3 性能测试结果 (28)4.4 系统分析与评价 (29)5. 总结与展望 (31)5.1 实验总结 (32)5.2 不足与改进 (33)5.3 展望与应用 (34)1. 内容综述本实验报告旨在详细阐述“C语言课程设计实验:学生信息管理系统”的设计与实现过程。
本系统以C语言为基础,采用结构化程序设计方法,旨在培养学生的编程能力和实际项目开发经验。
报告首先介绍了系统的背景和设计目标,随后对系统的主要功能模块进行了详细描述,包括学生信息录入、查询、修改和删除等功能。
此外,报告还对系统设计过程中遇到的技术难点、解决策略以及测试结果进行了分析,最后总结了实验的收获和不足,为后续的改进工作提供了参考。
通过本实验,学生不仅掌握了C语言编程的基本技能,还学会了如何将理论知识应用于实际项目中,提高了软件工程实践能力。
1.1 实验背景随着信息技术的飞速发展,数据管理在各个领域都扮演着越来越重要的角色。
报告内容:1.管理系统的功能说明这是一个用来进行文件管理的系统,能够实现对文件信息(包括文件号、文件名、文件性质、创建日期、文件大小)的浏览、创建、修改、搜索等功能。
2.储存数据的描述储存的数据由Flies类完成,Flies类中设置了num,name,type,date,space 5个成员来分别记录数据的文件号、文件名、文件性质、创建日期、文件大小。
(便于测试事先录入了5个初始数据)3.概要设计说明源程序主要分为3个部分:1.用于储存数据的Flies类(其中包括修改数据的函数check以及显示数据内容display)。
2.实现系统功能的函数(包括主菜单显示函数menu、增加数据函数add、用于查询数据的函数search1,search2)。
3.主函数。
4.源程序#include <iostream>#include <string>using namespace std;class Flies{ //定义Flies类public:string num,name,type,date,space; //flies类的成员Flies(){}Flies(string n,string N,string T,string D,string S){num=n;name=N;type=T;date=D;space=S;}void check() //修改flies类成员的函数check {cout<<"输入新的文件号:";cin>>num;cout<<"输入新的文件名:";cin>>name;cout<<"输入新的文件类型:";cin>>type;cout<<"输入新的创建日期:";cin>>date;cout<<"输入新的文件大小:";cin>>space;}void display() //显示flies类成员内容的函数display {cout<<"文件号:"<<num<<endl;cout<<"文件名:"<<name<<endl;cout<<"文件类型:"<<type<<endl;cout<<"创建日期:"<<date<<endl;cout<<"文件大小:"<<space<<endl;cout<<endl;}};void menu() //显示主菜单的函数menu {cout<<"*--------------------------*"<<endl;cout<<"| Menu |"<<endl;cout<<"| 输入:T (浏览数据) |"<<endl;cout<<"| A (增加数据) |"<<endl;cout<<"| C (修改数据) |"<<endl;cout<<"| S (查询数据) |"<<endl;cout<<"| Q (退出程序) |"<<endl;cout<<"| |"<<endl;cout<<"*--------------------------*"<<endl;};Flies add() //添加新文件的函数add {string num,name,type,date,space;cout<<"输入文件号:";cin>>num;cout<<"输入文件名:";cin>>name;cout<<"输入文件类型:";cin>>type;cout<<"输入创建日期:";cin>>date;cout<<"输入文件大小:";cin>>space;Flies b(num,name,type,date,space);return b;}void search1(Flies a[],int Num) //按文件名查找对象的函数search1 { int count,i;string V;cout<<"输入要查找的文件名:";cin>>V;cout<<"查找结果为:"<<endl;for(i=0,count=0;i<Num;i++){if (a[i].name==V)a[i].display();elsecount++;}if(count==Num)cout<<"空"<<endl;cout<<endl;}void search2(Flies a[],int Num) //按文件类型查找对象的函数search2 { int count,i;string V;cout<<"输入要查找的文件类型:";cin>>V;cout<<"查找结果为:"<<endl;for(i=0,count=0;i<Num;i++){if (a[i].type==V)a[i].display();elsecount++;}if(count==Num)cout<<"空"<<endl;cout<<endl;}int main() //主函数{static int Num=5;char n,x;int i;Flies A("01","windows","dll","2012/2/3","20k"), //设置初始文件B("02","office word","doc","2012/4/12","500k"),C("03","Warcarft III","exe","2012/6/1","1.2G"),D("04","homework","txt","2012/12/7","128k"),E("05","Mylove","mp3","2013/6/13","4M");Flies a[]={A,B,C,D,E};while(1) {cout<<"****************************************************"<<endl;cout<<endl;menu();cout<<endl;cout<<"****************************************************"<<endl;cout<<"选择功能:"; //程序功能选择的实现cin>>n;if(n=='Q')break;switch (n){case 'T':for(i=0;i<Num;i++){a[i].display();}break;case 'A':a[Num]=add();Num++;break;case 'C':cout<<"需要修改第几个文件:";cin>>i;if(0<i&&i<=Num){a[i-1].check();break;}elsecout<<"该文件不存在,请确认"<<endl;break;case 'S':cout<<"(1)按文件名查找(2)按文件类型查找选择你需要的方式:";cin>>x;switch(x){case '1':search1(a,Num);break;case '2':search2(a,Num);break;default:cout<<"输入错误,请正确输入"<<endl;cout<<endl;break;}break;default:cout<<"输入错误,请正确输入"<<endl;cout<<endl;break;}}cout<<"谢谢使用,再见"<<endl;return 0;}5.测试分析主界面浏览初始数据(T)增加数据(A)修改数据(C)查新数据(S)退出程序(Q)6.总结报告总体来说这次设计还是比较顺利的,整个程序的内容设计基本上都在平时作业中出现过,也都是基础内容,由此可见平时的学习是十分重要的。
课程信息管理系统c语言课程设计一、课程目标知识目标:1. 让学生掌握C语言中数组、结构体和文件操作等基本知识,并能够运用这些知识设计简单的信息管理系统。
2. 使学生了解课程信息管理系统的基本功能,如增加、删除、修改和查询等。
技能目标:1. 培养学生运用C语言进行程序设计的能力,能够独立编写、调试和运行简单的信息管理系统程序。
2. 培养学生分析问题、解决问题的能力,使其能够根据需求进行系统功能的设计和实现。
情感态度价值观目标:1. 培养学生对待编程的兴趣和热情,激发他们主动学习和探索的精神。
2. 培养学生的团队协作意识,学会与他人共同解决问题,提高沟通与协作能力。
3. 引导学生认识到编程在现代社会中的重要作用,培养他们利用技术手段解决实际问题的意识。
课程性质分析:本课程为C语言课程设计,旨在让学生将所学的C语言知识应用于实际项目中,提高编程实践能力。
学生特点分析:学生已具备一定的C语言基础,对数组、结构体和文件操作等知识有一定的了解,但可能缺乏将这些知识综合运用的经验。
教学要求:1. 结合课程信息管理系统的实际需求,引导学生运用所学知识进行程序设计。
2. 注重培养学生的动手实践能力,鼓励学生积极参与课程设计和讨论。
3. 关注学生的个体差异,提供有针对性的指导,帮助每位学生达成课程目标。
二、教学内容1. 数组与字符串操作:回顾数组的基本概念,掌握一维、二维数组的使用,以及字符串的存储和处理方法。
结合课程设计,实现对课程信息的批量存储和显示。
2. 结构体与链表:讲解结构体的定义和用法,引导学生利用结构体表示课程信息,并掌握链表的基本操作,如增加、删除节点等,以实现课程信息的动态管理。
3. 文件操作:介绍文件的基本概念,教授文件的打开、关闭、读写等操作,使学生能够将课程信息保存到文件中,并从文件中读取数据。
4. 函数与模块化编程:强调模块化编程的重要性,让学生掌握函数的定义、调用和参数传递方法,将程序划分为多个功能模块,提高代码的可读性和可维护性。
班级档案管理系统c课程设计语言一、引言1.1 项目背景随着信息技术的不断发展,各行各业都逐渐向数字化、信息化方向转变。
教育领域也不例外,学校班级档案管理系统的建设已经成为了教育信息化建设的重要组成部分。
班级档案管理系统是指对各个班级的学生档案进行管理和维护,包括学生基本信息、家庭联系方式、考试成绩、奖惩记录等内容。
1.2 项目目标本项目旨在开发一个功能完备的班级档案管理系统,能够满足学校对班级档案管理的需求,同时提高教师和管理员工作效率。
二、需求分析2.1 功能需求分析(1)用户登录:用户通过输入账号和密码登录系统。
(2)学生档案管理:管理员可以添加、删除和修改学生档案信息,并能够查询和打印学生档案。
(3)成绩管理:管理员可以录入和查询学生考试成绩,并能够生成成绩统计报表。
(4)奖惩记录:管理员可以添加、删除和修改学生奖惩记录,并能够查询和打印奖惩记录。
(5)家长联系方式:管理员可以录入和查询学生家长联系方式,并能够打印学生家长通讯录。
(6)系统设置:管理员可以对系统进行设置,包括修改管理员账号和密码、备份和恢复数据等。
2.2 非功能需求分析(1)易用性:系统界面简洁明了,操作简单方便。
(2)可靠性:系统具有良好的稳定性和可靠性,能够保证数据的安全性和完整性。
(3)安全性:系统具有较高的安全性,包括用户权限管理、数据加密等措施。
三、技术选型3.1 开发语言本项目采用C#语言进行开发。
C#是一种面向对象的编程语言,具有良好的扩展性和可维护性,同时也是Windows平台上广泛使用的编程语言之一。
3.2 开发工具本项目采用Visual Studio 2019作为开发工具。
Visual Studio 2019是微软公司推出的一款强大的集成开发环境,支持多种编程语言,并提供了丰富的开发工具和组件库,能够极大地提高开发效率。
四、系统设计4.1 数据库设计本项目采用MySQL数据库进行数据存储。
数据库中包含以下表:(1)学生档案表:存储学生基本信息、家庭联系方式等内容。
矿产资源开发利用方案编写内容要求及审查大纲
矿产资源开发利用方案编写内容要求及《矿产资源开发利用方案》审查大纲一、概述
㈠矿区位置、隶属关系和企业性质。
如为改扩建矿山, 应说明矿山现状、
特点及存在的主要问题。
㈡编制依据
(1简述项目前期工作进展情况及与有关方面对项目的意向性协议情况。
(2 列出开发利用方案编制所依据的主要基础性资料的名称。
如经储量管理部门认定的矿区地质勘探报告、选矿试验报告、加工利用试验报告、工程地质初评资料、矿区水文资料和供水资料等。
对改、扩建矿山应有生产实际资料, 如矿山总平面现状图、矿床开拓系统图、采场现状图和主要采选设备清单等。
二、矿产品需求现状和预测
㈠该矿产在国内需求情况和市场供应情况
1、矿产品现状及加工利用趋向。
2、国内近、远期的需求量及主要销向预测。
㈡产品价格分析
1、国内矿产品价格现状。
2、矿产品价格稳定性及变化趋势。
三、矿产资源概况
㈠矿区总体概况
1、矿区总体规划情况。
2、矿区矿产资源概况。
3、该设计与矿区总体开发的关系。
㈡该设计项目的资源概况
1、矿床地质及构造特征。
2、矿床开采技术条件及水文地质条件。