C语言程序设计之实验室设备管理系统源代码
实验设备管理系统设计C源代码
![实验设备管理系统设计C源代码](https://img.taocdn.com/s3/m/2ac9e82d4028915f814dc2e6.png)
源代码#include <iostream>#include <cstdlib>#include <string>#include <fstream>#include <sstream>using namespace std;class Node //结点类,用于存放客户的各种信息{publiclong id; //实验设备编号string name; //名称string type //随便类型string suoshushiyanshi; //实验设备所属实验室string buytime; //购买时间string price; //价格string amount; //库存量string shengchanriqi; //生产日期string shiyongshouming; //使用寿命string weight; //重量Node *next; //指向下一结点的指针Node(long id=000,string nname="noname",string ntype="unkown".string nsuoshushiyanshi="unknow",string nbuytime="unknow",string nprice="unknow",string namount="unknow",string nshengchanriqi="unkown",string nshiyongshouming="unknow",string nweight="unknow");//构造函数,初始化变量};class Link//Link 类,把数据以链表的形式存储,链表的每个结点为一个Node对象{private:Node *head;//链表的头指针,为Node对象类型的指针public:Link();//构造函数,初始化变量bool link IsEmpty();//判断链表是否为空void linkInsert(Node *newnode);//向链表中插入新的结点bool linkDelete(int nid);//从链表中删除的结点void linkClear();//清空链表中数据void linkView();//查看链表中数据Node* linkFind(int nid);//在链表中查找id为nid结点,返回指向该结点的指针Node* getHead();//获取头指针};Node::Node(long nid,string nname,string ntype,string nsuoshushiyanshi,string nbuytime,string nprice,string namount,string nshengchanriqi,string nshiyongshouming,string nweight){id=nid;name=nname;type=ntypesuoshushiyanshi=nsuoshushiyanshi;buytime=nbuytime;price=nprice;amount=namount;shengchanriqi=nshengchanriqi;shiyongshouming=nshiyongshouming;weight= nweight;next=NULL;}Link::Link() //构造函数,初始化链表为空{head=NULL;}bool Link::linkIsEmpty() //判断链表是否为空,空则返回true{return(head==NULL);}void Link::linkInsert(Node *newnode)//按id值从小到大的顺序,插入新的结点{Node *pl;if(!head)//链表为空的情况head=newnode;else if((head->id)>(newnode->id))//插入到第一个结点的情况{newnode->next=head;head=newnode;}else//插入到第二个及以后情况{pl=head;while(1){if(!(pl->next)){pl->next=newnode;break;}else if((pl->next)->id>newnode->id){newnode->next=pl ->next;pl ->next=newnode;break;}pl=pl ->next;}}}bool Link::linkDelete(int nid)//删除结点,成功则返回true {Node *p;if(head==NULL)//链表为空的情况return false;if(head->id==nid)//删除的为第一个结点的情况{head=head->next;return true}p=head;while(p->next)//删除的为第二个及以后的情况{if((p->next)->id==nid){p->next=(p->next)->next;return true;}p=p->next;}return false;}void Link::linkClear()//清空链表{head=NULL;}Node* Link::linkFind(int nid)//查找id 值为nid的结点,返回该结的的指针{Node *p=head; //没找到符合条件的结点的话,返回的指针值为NULL while(p){if(p->id==nid)break;elsep=p->next;}return p;}void Link::linkView()//显示链表数据{Node *p=head;while(p){cout<<"实验设备编号:"<<p->id<<endl;cout<<"名称:"<<p->name<<endl;cout<<"类型:"<<p->type<<endl;cout<<"所属实验室:"<<p->suoshushiyanshi<<endl;cout<<"购买时间:"<<p->buytime<<endl;cout<<"价格:"<<p->price<<endl;cout<<"库存量:"<<p->amount<<endl;cout<<"生产日期:"<<p->shenchanriqi<<endl;cout<<"使用寿命:"<<p->shiyongshouming<<endl;cout<<"重量:"<<p->weight<<endl;cout<<"*******************************************************"<<endl;p=p->next;}}Node* Link::getHead(){return head;}//类Shebei,用于包装Link类及菜单操作class Shebei{private:Link clink;//Link 对象成员bool k;//记录数据是否被修改public:Shebei();void ShebeiClear();void ShebeiInsert();void ShebeiDelete();void ShebeiFind();void ShebeiModify();void ShebeiView();void ShebeiLoad();void ShebeiSave();void Exit();//退出程序void showMenu();//显示菜单void showTip();//显示操作提示void doMenu(char n);//执行相应菜单项功能};Shebei:: Shebei(){Link();//调用成员对象的构造函数ShebeiLoad();从文件中读取数据,创建链表k=false;//设置数据被修改}void Shebei::ShebeiClear()//清空设备记录{clink.linkClear();cout<<"成功清空设备信息记录!"<<endl;}void Shebei::ShebeiInsert()//插入设备记录{Node *p=new Node();cout<<"请输入设备编号:";cin>>p->id;cout<<"请输入名称:";cin>>p->name;cout<<"请输入类型:";cin>>p->type;cout<<"请输入所属实验室:";cin>>p->suoshushiyanshi;cout<<"请输入购买时间:";cin>>p->buytime;cout<<"请输入价格:";cin>>p->price;cout<<"请输入库存量:";cin>>p->amount;cout<<"请输入生产日期:";cin>>p->shengchanriqi;cout<<"请输入设备重量:";cin>>p->weight;if(!clink.linkFind(p->id))判断设备信息是否存在{clink.linkInsert(p);k=true;}elsecout<<"设备编号为"<<p->id<<"的设备已存在,插入失败! "<<endl; }void Shebei::ShebeiDelete()//删除设备记录{long i;if(clink.linkIsEmpty())//链表为空的情况cout<<"没有设备记录! "<<endl;else{cout<<"请输入设备编号:";cin>>i;if(clink.linkDelete(i)){cout<<"成功删除编号为"<<i<<"的实验记录!"<<endl;k=true;}elsecout<<"没有找到编号为"<<i<<"的设备!"<<endl;}}void Shebei::ShebeiFind()//查找某编号的设备记录{long n;Node *p;if(clink.linkIsEmpty())//链表为空的情况cout<<"没有设备记录!"<<endl;else{cout<<"请输入要查找的设备的编号:";cin>>n;p=clink.linkFind(n);//获得找到的结点的指针if(p)//指针值不为NULL时{cout<<"实验设备编号:"<<p->id<<endl;cout<<"名称:"<<p->name<<endl;cout<<"类型:"<<p->type<<endl;cout<<"所属实验室:"<<p->suoshushiyanshi<<endl;cout<<"购买时间:"<<p->buytime<<endl;cout<<"价格:"<<p->price<<endl;cout<<"库存量:"<<p->amount<<endl;cout<<"生产日期:"<<p->shengchanriqi<<endl;cout<<"使用寿命:"<<p->shiyongshouming<<endl;cout<<"重量:"<<p->weight<<endl;}else//指针值为NULL时cout<<"没有找到编号为"<<n<<"的设备记录!"<<endl;}}void Shebei::ShebeiModify()//修改某编号的设备信息{long n;Node *p;if(clink.linkIsEmpty())//链表为空的情况cout<<"没有设备记录!"<<endl;else{cout<<"请输入要修改的设备的编号:";cin>>n;p=clink.linkFind(n);//获得找到的结点的指针if(p)//指针值不为NULL时{cout<<"实验设备编号:"<<p->id<<endl;cout<<"名称:"<<p->name<<endl;cout<<"类型:"<<p->type<<endl;cout<<"所属实验室:"<<p->suoshushiyanshi<<endl;cout<<"购买时间:"<<p->buytime<<endl;cout<<"价格:"<<p->price<<endl;cout<<"库存量:"<<p->amount<<endl;cout<<"生产日期:"<<p->shengchanriqi<<endl;cout<<"使用寿命:"<<p->shiyongshouming<<endl;cout<<"重量:"<<p->weight<<endl;cout<<"请输入新的设备信息"<<endl;cout<<"请输入设备编号:";cin>>p->id;cout<<"请输入名称:";cin>>p->name;cout<<"请输入类型:";cin>>p->type;cout<<"请输入所属实验室:";cin>>p->suoshushiyanshi;cout<<"请输入购买时间:";cin>>p->buytime;cout<<"请输入价格:";cin>>p->price;cout<<"请输入库存量:";cin>>p->amount;cout<<"请输入生产日期:";cin>>p->shengchanriqi;cout<<"请输入设备重量:";cin>>p->weight;}else//指针值为NULL时cout<<"没有找到编号为"<<n<<"的设备记录! "<<endl;}}void Shebei::ShebeiView()//显示所有设备的记录{if(clink.linkIsEmpty())cout<<"没有设备记录! "<<endl;elseclink.linkView();}void Shebei::ShebeiLoad()//从文件中读入数据,创建链表{Node *p;long nid;ifstream infile("data.txt");if(!infile)cerr<<"错误:数据文件不能打开!\n";elsewhile(infile>>nid)//读取客户,直到读空{p=new Node();p->id=nid;infile>>p->name>>" "; //读取名称infile>>p->type>>" ";infile>>p->suoshushiyanshi>>" ";infile>>p->buytime>>" ";infile>>p->price>>" ";infile>>p->amount>>" ";infile>>p->shengchanriqi>>" ";infile>>p->weight>>" ";clink.linkInsert(p);}infile.close(); //关闭文件}void Shebei::ShebeiSave()//将数据保存到文件{Node *p=clink.getHead();ofstream outfile("data.txt");if(!outfile)cerr<<"错误:数据文件不能打开!\n";else{while(p){outfile<<p->id<<" "<<p->name<<" "<<p->type<<""<<p->suoshushiyanshi<<" "<<p->buytime<<" "<<p->price<<" "<<p->amount<<" "<<p->shengchanriqi<<" "<<p->weight<<" "<<endl;p=p->next;}k=false;cout<<"保存成功!"<<endl;}}void Shebei::Exit(){char s='Y';if(k)//判断数据是否修改{cout<<"数据已经改变,是否保存?(y/n):"cin>>s;if(s=='Y'lls=='Y')ShebeiSave();}cout<<"已安全退出,";system("pause");exit(0);}void Shebei::showMenu()cout<<"\t\t*********************************************"<<endl; cout<<"\t\t* 实验室设备管理系统*"<<endl;cout<<"\t\t* *"endl;cout<<"\t\t* 1--清除所有设备信息*"endl;cout<<"\t\t* *"endl;cout<<"\t\t* 2--添加:增加一个设备到设备信息中*"endl;cout<<"\t\t* *"endl;cout<<"\t\t* 3--删除:删除指定设备数据*"endl;cout<<"\t\t* *"endl;cout<<"\t\t* 4--查找:根据设备数据查找设备信息*"endl;cout<<"\t\t* *"endl;cout<<"\t\t* 5--修改:修改指定设备信息*"endl; cout<<"\t\t* *"endl; cout<<"\t\t* 6--显示:在屏幕上显示所有设备的消息*"endl; cout<<"\t\t* *"endl; cout<<"\t\t* 7--存储:将设备信息保存在一个文件中*"endl; cout<<"\t\t* *"endl; cout<<"\t\t* 0--退出:安全的退出本系统*"endl;cout<<"\t\t********************************************"endl;}void Shebei::showTip(){cout<<endl;cout<<"*****************操作完成***************"<<endl;cout<<"***************选择0--7继续************"<<endl;cout<<"请选择:";}void Shebei::doMenu(char n){switch(n){case'1':ShebeiClear();break;case'2':ShebeiInsert();break;case'3':ShebeiDelete();break;case'4':ShebeiFind();break;case'5':ShebeiModify();break;case'6':ShebeiView();break;case'7':ShebeiSave();break;case'0':Exit();break;default:cout<<"输入错误!";}}int main(){Shebei c;char i='9';c.showMenu();cout<<"欢迎来到实验室设备管理系统:"<<endl;cout<<"请选择你需要的服务:";while(1){cin>>i;system("cls"); //清除屏幕c.showMenu();c.doMenu(i);c.showTip();}return 0;}。
C语言课程设计-实验室设备信息管理系统
![C语言课程设计-实验室设备信息管理系统](https://img.taocdn.com/s3/m/b4eab0dd87c24028905fc352.png)
二○一五~二○一六学年第一学期电子与信息工程系课程设计报告书课程名称:程序设计基础实践班级:学号:姓名:指导教师:二○一五年十二月1..实验室设备信息管理系统功能(1). 每一条记录包括实验室的设备编号、设备名称、设备型号、设备价格、设备购买日期信息。
(2). 实验设备信息录入:可以一次完成诸多条记录的录入。
(3). 实验设备信息更改:可实现对实验设备信息更改的信息进行适当的修改。
(4). 报废设备信息删除:对实验损毁设备信息予以删除。
(5). 实验设备信息查询:本系统提供两种查询实验设备的方法:1.按器材名称查询.2.按器材编号查询.从而完成按实验设备的查找查找功能,并显示。
(6). 实验设备信息排序:根据实验设备的编号进行排序,以实现实验设备的有序全局查看。
实验设备信息显示功能:完成全部学生记录的显示。
(7). 简单帮助:提供实验室负责人简单的信息。
(8). 保存功能:将学生记录保存在任何自定义的文件中,如保存在:c:\score。
(9). 读取功能:将保存在文件中的学生记录读取出来。
(10). 有一个清晰美观界面来调用各个功能2.设计内容2.1 程序的总体设计整个系统除了主函数外,另外还有11个函数,实现以下功能:实验室设备录入功能、显示功能、查找功能、排序功能、读出与写入取功能。
各个函数的详细设计说明分别如下:2.2 数据结构使用C语言创建的结构体如下:typedef Equipment /*定义数据结构*/{char bianhao; //编号char name[20]; //名称char model[20]; //型号bnmchar price[20]; //价格char buy_date[20]; //购买日期};3 详细设计3.1实验设备管理系统主程序模块设计控制整个程序的运行,通过主函数模块分别调用各个模块,实现各项功能,流程如图1所示。
通过switch进入分支结构从而调用执行不同的函数,以实现菜单选择的功能。
实验设备管理系统-c语言实现
![实验设备管理系统-c语言实现](https://img.taocdn.com/s3/m/4161b8a3ab00b52acfc789eb172ded630a1c9843.png)
一、设计目的1.1 设计题目:设计实现一个实验设备管理系统。
实验设备信息包括:设备编号,设备种类(如:微机、打印机、扫描仪等等),设备名称,设备价格,设备购入日期,是否报废,报废日期等。
1.2 设计要求(1)能够完成对设备的录入和修改(2)对设备进行分类统计(3)设备的破损耗费和遗损处理(4)设备的查询(5)采用二进制文件方式存储数据,系统以菜单方式工作1.3 系统功能需求分析系统功能需求:设备信息的录入、修改;设备分类统计;设备破损耗费和遗损处理;设备信息查询;二进制文件方式存储数据;菜单方式工作;用户操作流程:运行程序后会弹出菜单界面,根据菜单界面的提示选择需要完成的相应功能即可完成操作。
数据处理流程:通过input函数将用户输入的各信息以二进制文件方式存储数据,后续可根据需要调用change函数、sort函数、search函数以及del函数进行数据的相应处理,最后通过output函数实现数据的输出显示。
二、总体设计实验设备管理系统功能结构图如下所示:三、详细设计3.1 结构体struct equipment_infor//定义结构体包含各设备信息{char ID[20]; //设备编号int sort; //设备种类(1代表微机 2代表打印机 3代表扫描机)char name[20]; //设备名称float price; //设备价格char buy_date[20]; //设备购买日期int state; //设备状态(报废为1,未报废为0)char scrap_date[20]; //设备报废日期}device[NUM];定义结构体数组,其中包含设备所有信息,方便数据信息的录入、输出等。
3.2 主要函数3.2.1 void load()加载已有数据函数void load() //加载已有数据{count=0;FILE* fp_5=fopen("binary.txt","rb");if(fp_5==NULL){return;}for(int i=0;;i++,count++){if(feof(fp_5)!=0){count--;break;}fread(&device[i], sizeof(struct equipment_infor),1,fp_5);}fclose(fp_5);}此函数实现了加载已有信息的功能,能够使得下次运行时上次的数据得以保留,同时计算出了count的值,可提供后续函数for循环的循环条件,一举两得。
C语言实验室设备管理系统
![C语言实验室设备管理系统](https://img.taocdn.com/s3/m/f82d526d192e45361066f55f.png)
C语言程序设计报告1 课程设计题目:实验室设备管理里系统实验设备信息包括:设备编号、设备种类(如:微机打印机扫描仪等等)、设备名称、设备价格、设备购入日期、是否报废、报废日期等。
试设计一实验设备信息管理系统,使之能提供以下功能:(1)能够完成对设备的录入和修改(2)对设备进行分类统计(3)设备的查询2 需求分析实验室设备信息用文件存储,提供文件的输入输出操作;要能够完成设备的录入和修改,需要提供设备添加和修改操作;实现对设备进行分类统计,需要提供排序操作;实现对设备查询需要提供查找操作,设备的查询可根据设备编号设备种类设备购入日期正常设备(未报废的)等多种方式查询;另外还要根据键盘式选择菜单以实现功能选择。
3总体设计与模块的划分整个系统可设计为实验设备信息输入模块实验设备信息添加模块实验设备信息修改模块实验设备分类统计模块和实验设备查询模块。
4 建立实验设备信息结构体结构体成员包括设备编号设备种类设备名称设备价格设备购入日期是否报废报废日期。
5应用程序功能详细说明程序运行后进入管理系统,显示目录:添加记录、修改记录、显示记录、分类统计、查询记录(1)添加记录系统提示用户在原有的基础上录入新的设备信息。
流程图如下:(2)修改记录系统要求用户输入要修改的设备ID号,这时系统会显示设备的具体信息,用户只需该设备新的信息按要求输入即可对信息进行修改。
流程图如下:(3)显示记录无记录退出,有记录者按要求输出。
流程图如下:(4)统计分类若有资料可以统计,则按要求分类统计输出。
流程图如下:(5)查询记录若信息为空,则不能查询。
流程图如下:(6)结束语通过本次c语言的程序设计,我不仅提高巩固了c语言的基础,也初学习了编写一个实用程序的流程,提高了动手操作能力,也提高了对编程的兴趣。
我相信经过努力后,我的编程能力一定会得到提高。
源程序代码清单:void main(){Node *equip;FILE *fp;int flag;Node *p,*q;printf("\t\t\t\t设备管理系统\n");equip=(Node*)malloc(sizeof(Node));equip->next=NULL;p=equip;fp=fopen("设备管理系统","wb+");q=(Node*)malloc(sizeof(Node));if(fread(q,sizeof(Node),1,fp)) /*将文件的内容放入接点中* /{q->next=NULL;p->next=q;p=q; /*将该接点挂入链表中*/}fclose(fp); /*关闭文件*/while(1){printf("********************目录***********************");printf("\n1添加记录\n");printf("\n2修改记录\n");printf("\n3显示记录\n");printf("\n4统计分类\n");printf(“\n5 查询记录\n”);printf("\n0*-EXIT-*\n");printf("请输入你要操作的序号:");scanf("%d",&flag);switch(flag){case 0: printf("\n>>>>>>>>>>提示:已经退出系统,ByeBye!\n");break;case 1: Add(equip); break; /*增加记录*/case 2: Modify(equip); break;/*修改记录*/case 3: Disp(equip); break;/*显示记录信息*/case 4: Tongji(equip); break;/*统计记录*/case 5:chaxun(equip);break;/*查询记录*/default: printf("\n>>>>>>>>>>提示:输入错误!\n"); break;}}}Struct shebei{ char ID[10]; char name[15]; char kind[15]; char over[15]; char yesno[10]; char time[10]; char price[10];}void Add(Node *equip) /*添加记录*/{Node *p,*r,*s;char id[10]; /*先用于输入ID,也用于判断是否跳出循环*/r=equip;s=equip->next; /*使s为第一个有用的结点*/while(r->next!=NULL) /*这个循环的作用是使r为最后一个有用的结点*/r=r->next; /*将指针置于最末尾*/while(1){printf(">>>>>>>>>>提示:输入0则返回主菜单!\n");printf("\n请你输入设备ID号:");scanf("%s",id);if(strcmp(id,"0")==0) break;p=(Node *)malloc(sizeof(Node)); /*申请空间*/strcpy(p->data.ID,id);printf("\n请输入设备名称:");scanf("%s",p->);printf("\n请输入设备种类:");scanf("%s",p->data.kind);printf("\n请输入报废日期:");scanf("%s",&p->data.over);printf("\n请输入设备是否报废:");scanf("%s",&p->data.yesno);printf("\n请输入设备购买时间:");scanf("%s",&p->data.time);printf("\n请输入设备价格:");scanf("%s",&p->data.price);printf(">>>>>>>>>>提示:已经完成一条记录的添加。
lab c c++ 实验室设备管理系统C C++源代码 完整版
![lab c c++ 实验室设备管理系统C C++源代码 完整版](https://img.taocdn.com/s3/m/3e6d6507bed5b9f3f90f1c7b.png)
fprintf(fp,"%s\n",current->factory);
fprintf(fp,"%s\n",current->buy_date);
//printf("%d %s %s %s %s ",current->num,current->name,current->model,current->factory,current->buy_date);
current = current->next;
}
fclose(fp);
}
//删除设备
void deleteEum){
if(head->next==NULL){
printf("没有设备!请先录入设备!");
char factory[20]; //厂家
char buy_date[20]; //购买日期
struct equipment *next;
char repair_time[20];
}Equipment;
void fprintE(Equipment *head); //将设备信息输出到文件
fclose(fp);
printf("记录成功!");
break;
}case 2:{
int t = 0;
printf("请输入查找编号:");
scanf("%d",&num);
printf("没有设备!请先录入设备!");
c程序课程设计--实验室管理系统
![c程序课程设计--实验室管理系统](https://img.taocdn.com/s3/m/2ee3a83c43323968011c9227.png)
目录1需求分析 (4)2 总体设计 (4)2.1程序的总体设计 (4)2.2数据结构 (5)3 详细设计 (6)3.1主控模块设计 (6)3.2实验设备信息录入模块设计 (7)3.3实验设备信息更改模块设计 (8)3.4实验设备信息删除模块设计 (9)4.主要函数功能描述 (10)4.1 添加设备函数addEequipment() (10)4.2 输入到文件函数fpintE (10)4.3 修改设备信息函数changeEquipment() (10)4.4 删除设备信息函数deleteEquipment() (10)5 测试与调试 (11)6 个人设计小结与心得体会 (12)参考文献 (12)致谢 (13)附件1 程序源代码 (13)前言现在,科学技术的飞速发展把人类社会推向了一个崭新的时代─信息时代。
这已是无可争议的事实;信息对社会经济发展的巨大推动作用,使其与物质能源一起并列为现代社会的三大支柱,这已在全社会达到共识。
随着对信息作为一种资源来管理的需求日益加强,信息研究领域出现了一种新的管理思想和模式─信息管理。
计算机管理以其快捷高效的特点在很多领域已经取代了传统的手工管理方式,尤其是在繁复琐碎的物资设备管理中,计算机管理手段的这一优势更显得十分突出。
与传统管理方式相比较,设备管理系统能更加有效的进行信息管理。
设备管理系统应用数据库,对信息数据以数据库形式表示,更容易更新和管理。
传统的管理方式往往以表格的形式进行管理,一旦数据过于庞大,要对这些数据进行管理时,就要花费大量的时间,而且很容易出错。
由于现代信息化的普及化,因此现代信息化的设备管理模式很快取代了传统模式的管理方式。
摘要在此次课程设计中我们小组的课设题目是实验室设备信息管理系统,我们使用软件Visual C++6.0及C语言来完成此次课程设计。
我在课设过程中实现了系统的主菜单,设备信息录入,设备信息修改,设备信息删除等功能。
利用开发程序对实验室设备进行方便、有效、合理的管理。
C语言-实验室设备管理系统
![C语言-实验室设备管理系统](https://img.taocdn.com/s3/m/a0fc7b06ee06eff9aef8076e.png)
精心整理C语言程序设计报告1 课程设计题目:实验室设备管理里系统实验设备信息包括:设备编号、设备种类(如:微机打印机扫描仪等等)、设备名称、设备价格、设备购入日期、是否报废、报废日期等。
试设计一实验设备信息管理系统,使之能提供以下功能:(1)能够完成对设备的录入和修改(2)对设备进行分类统计(3)设备的查询2 需求分析实验室设备信息用文件存储,提供文件的输入输出操作;要能够完成设备的录入和修改,需要提供设备添加和修改操作;实现对设备进行分类统计,需要提供排序操作;实现对设备查询需要提供查找操作,设备的查询可根据设备编号设备种类设备购入日期正常设备(未报废的)等多种方式查询;另外还要根据键盘式选择菜单以实现功能选择。
3总体设计与模块的划分整个系统可设计为实验设备信息输入模块实验设备信息添加模块实验设备信息修改模块实验设备分类统计模块和实验设备查询模块。
主函数流程图:N+4 建立实验设备信息结构体 结构体成员包括设备编号 设备名称 部门编号 部门名称 设备价格 设备购买时间 是否报废 报废日期。
5应用程序功能详细说明程序运行后进入管理系统,显示目录:录入设备信息,修改设备信息,查询设备信息,统计设备信息,报废设备信息,退出录入设备信息 系统提示用户在原有的基础上录入新的设备信息。
流程图如下:录入设备信息修改设备信息查询设备信息统计设备信息报废设备信息退出设备管理系统设计开始 显示一系列功能选输入n,判断据n 值调用各功能模结束开始输入设备编号,并将(1)修改记录系统要求用户输入要修改的设备编号,这时系统会显示设备的具体信息,用户只需该设备新的信息按要求输入即可对信息进行修改。
流程图如下:开始判断是否有资料可以没有资料可以统计输入要统计的分类序按输入序号调用各功结束(2)显示记录无记录退出,有记录者按要求输出。
流程图如下:开(3) 统计分类 若有资料可以统计,则按要求分类统计输出。
流程图如下:(4) 查询记录 若信息为空,则不能查询。
实验室管理系统—C语言
![实验室管理系统—C语言](https://img.taocdn.com/s3/m/2129ea85a6c30c2259019ebf.png)
西安郵電大学软件课程设计报告题目:实验室设备管理系统院系名称:电子工程学院专业名称:电子信息工程班级:1204班内序号:5学生姓名:诺贝尔杨时间:2013年3月18日至2013年3月29日1.课程设计目的实验设备信息包括:设备编号,设备种类(如:微机、打印机、扫描仪等等),设备名称,设备价格,设备购入日期,是否报废,报废日期等。
主要功能:1.录入设备信息2.修改设备信息3.查询设备信息(1)按设备编号查询(2)按设备名称查询4.对设备按种类进行分类统计5.报废设备登记。
6.报废设备统计。
2.设计思路需求分析实验室设备信息用文件存储,提供文件的输入输出操作;要能够完成设备的录入和修改,需要提供设备添加和修改操作;实现对设备进行分类统计,需要提供排序操作;实现对设备查询需要提供查找操作,设备的查询可根据设备编号设备种类设备购入日期正常设备(未报废的)等多种方式查询;另外还要根据键盘式选择菜单以实现功能选择。
整个系统可设计为实验设备信息输入模块实验设备信息修改模块实验设备分类统计模块实验设备查询模块和实验设备报废信息模块。
建立实验设备信息结构体,结构体成员包括设备编号设备种类设备名称设备价格设备购入日期是否报废报废日期。
3.功能模块图5.程序代码#include""#include""#define null 0int t=0;int mmcsz=0;int mima;int menu();d);if(strcmp(sb[t].id,"0")==0) main();printf("\n请输入设备名称:");scanf("%s",sb[t].name);printf("\n请输入设备种类:");scanf("%s",sb[t].kind);printf("\n请输入报废日期:");scanf("%s",sb[t].over);printf("\n请输入设备是否报废,1、没报废,0、报废:"); scanf("%d",&sb[t].yesno);printf("\n请输入设备购买时间:");scanf("%s",sb[t].time);printf("\n请输入设备价格:");scanf("%s",sb[t].price);printf("提示:已经完成一条记录的添加。
c语言科研管理系统--源代码
![c语言科研管理系统--源代码](https://img.taocdn.com/s3/m/b04c3a21647d27284b7351cb.png)
#include<stdio.h>#include<conio.h>#include<stdlib.h>#include<math.h>#include<string.h>//头文件struct project{char pn[30];//项目名称char name[30];//项目主持人的名字char sex;//项目支持人的性别int age;//项目主持人的年龄char pnum[15];//项目主持人的电话号码char pt[15];//项目编号char time[30];//立项时间char danwei[10];//项目所属单位char pj[10];//项目级别char qixian[40];//研究期限char chengyuan[50];//研究人员int jingfei;//下拨经费int sjf;//学校配套经费};struct project a[100];int r=0;//全局变量,用于计输入项目的个数void shuru(struct project *p)//输入项目信息{int i;char x;FILE *file;if((file=fopen("c:\\project.dat","rb+"))==NULL){file = fopen("c:\\project.dat", "wb+");}do{printf("请输入第%d个的项目名称\n",r+1); fflush(stdin);scanf("%s",(p+r)->pn);printf("请输入项目主持人\n"); fflush(stdin);gets((p+r)->name);printf("请输入性别,男生:m 女生:w\n"); fflush(stdin);scanf("%c",&(p+r)->sex);printf("请输入年龄\n"); fflush(stdin);scanf("%d",&(p+r)->age);printf("请输入项目主持人的手机号码\n"); fflush(stdin);gets((p+r)->pnum);printf("请输入项目编号\n");fflush(stdin);gets((p+r)->pt);printf("请输入立项时间\n");fflush(stdin);scanf("%s",(p+r)->time);printf("请输入项目所属单位\n");fflush(stdin);scanf("%s",(p+r)->danwei);printf("请输入项目级别\n");fflush(stdin);scanf("%s",(p+r)->pj);printf("请输入研究期限\n");fflush(stdin);scanf("%s",(p+r)->qixian);printf("请输入研究人员\n");fflush(stdin);gets((p+r)->chengyuan);printf("请输入下拨经费\n");fflush(stdin);scanf("%d",&(p+r)->jingfei);printf("请输入学校配套经费\n");fflush(stdin);scanf("%d",&(p+r)->sjf);r++;printf("是否继续输入?n/y\n"); fflush(stdin);scanf("%c",&x);}while(x=='y');//当输入为y时,继续输入,直到输入是n为止for(i=0;i<r;i++)fwrite((p+i),sizeof(struct project),1,file);fclose(file); /* 关闭文件*/fflush(stdin);system("cls");}void shuchu(struct project *p)//输出项目信息{int i=0,s;FILE *file;if((file=fopen("c:\\project.dat","r"))==NULL)//打开文件{printf("Open error!!\n");getch();exit(0);}printf("项目名称项目主持人的姓名性别年龄手机号码项目编号立项时间项目单位项目级别项目期限研究人员下拨经费校配经费\n");for(s=0;s<r;s++){fread(p+s,sizeof(struct project),1,file);printf("%-14s",p[s].pn);printf("%-15s",p[s].name);printf("%-5c",p[s].sex);printf("%-6d",p[s].age);printf("%-12s",p[s].pnum);printf("%-11s",p[s].pt);printf("%-12s",p[s].time);printf("%-10s",p[s].danwei);printf("%-8s",p[s].pj);printf("%-12s",p[s].qixian);printf("%-13s",p[s].chengyuan);printf("%-10d",p[s].jingfei);printf("%-10d",p[s].sjf);printf("\n");}fclose(file);}void add(struct project *p)//添加项目信息{shuru(a);//调用输入函数}void xianshi(struct project *p)//根据要求输出信息{char i[30],c[15];int j,s;FILE *file;if((file=fopen("c:\\project.dat","r"))==NULL){printf("Open error!!\n");getch();exit(0);}printf("****************************\n");printf("*********请输入类型*********\n");printf("*1:按照老师姓名查找科研信息*\n");printf("*2:按照手机号码查询老师信息*\n");printf("****************************\n");scanf("%d",&s);if(s==1){printf("请输入你想查询老师的姓名\n");fflush(stdin);gets(i);for(j=0;j<r;j++){fread(p+j,sizeof(a),1,file);if(strcmp(p[j].name,i)==0)break;printf("项目名称项目主持人的姓名性别年龄手机号码项目编号立项时间项目单位项目级别项目期限研究人员下拨经费校配经费\n");fread(p+j,sizeof(a),1,file);printf("%-14s",p[j].pn);printf("%-15s",p[j].name);printf("%-5c",p[j].sex);printf("%-6d",p[j].age);printf("%-12s",p[j].pnum);printf("%-11s",p[j].pt);printf("%-12s",p[j].time);printf("%-10s",p[j].danwei);printf("%-8s",p[j].pj);printf("%-12s",p[j].qixian);printf("%-13s",p[j].chengyuan);printf("%-10d",p[j].jingfei);printf("%-10d",p[j].sjf);printf("\n");fclose(file);}if(s==2){printf("请输入手机号码\n");fflush(stdin);gets(c);for(j=0;j<r;j++){fread(p+j,sizeof(a),1,file);if(strcmp(p[j].pnum,c)==0)break;}printf("老师的姓名为:%s\n",p[j].name);fclose(file);}}void xiugai(struct project *p)//修改信息{int b,c;char i[15];FILE *file;if((file=fopen("c:\\project.dat","wb"))==NULL){printf("Open error!!\n");getch();exit(0);printf("请输入你想修改的项目编号\n");fflush(stdin);gets(i);for(b=0;b<r;b++){fread(p+b,sizeof(struct project),1,file);if(strcmp(p[b].pt,i)==0)break;}if(strcmp(p[b].pt,i)!=0)//判断上一个循环后是否找到与数组i相匹配的项目编号{ printf("无此项目编号!");xiugai(a);//返回到修改函数重新输入}else{printf("请重新输入项目名称\n"); fflush(stdin);//重新输入项目信息scanf("%s",(p+b)->pn);printf("请输入项目主持人\n"); fflush(stdin);gets((p+b)->name);printf("请输入性别,男生:m 女生:w\n"); fflush(stdin);scanf("%c",&(p+b)->sex);printf("请输入年龄\n"); fflush(stdin);scanf("%d",&(p+b)->age);printf("请输入项目主持人的手机号码\n"); fflush(stdin);gets((p+b)->pnum);printf("请输入立项时间\n");fflush(stdin);scanf("%s",(p+b)->time);printf("请输入项目所属单位\n");fflush(stdin);scanf("%s",(p+b)->danwei);printf("请输入项目级别\n");fflush(stdin);scanf("%s",(p+b)->pj);printf("请输入研究期限\n");fflush(stdin);scanf("%s",(p+b)->qixian);printf("请输入研究人员\n");fflush(stdin);gets((p+b)->chengyuan);printf("请输入下拨经费\n");fflush(stdin);scanf("%d",&(p+b)->jingfei);printf("请输入学校配套经费\n");fflush(stdin);scanf("%d",&(p+b)->sjf);for(c=0;c<b;c++)//把信息重新输进去fwrite(p+c,sizeof(struct project),1,file);fwrite(p+b,sizeof(struct project),1,file);for(c=b+1;c<r;c++)fwrite(p+c,sizeof(struct project),1,file);fclose(file);printf("修改成功!!");}}void shanchu(struct project *p)//删除信息{int i,j;char b[15];//保存输入的项目编号FILE *file;if((file=fopen("c:\\project.dat","wb"))==NULL)//打开文件{printf("打开错误!!\n");getch();exit(0);}printf("请输入想删除的项目编号\n");fflush(stdin);gets(b);//输入字符串for(j=0;j<r;j++)//寻找与输入相同的项目编号{fread(p+j,sizeof(struct project),1,file);if(strcmp(p[j].pt,b)==0)break;}if(strcmp(p[j].pt,b)!=0)//判断上一个循环后是否找到与数组i相匹配的项目编号{printf("无此项目编号!!\n");shanchu(a);//返回到删除函数重新输入}else if(j==r-1){r--;for(i=0;i<r;i++,p++)fwrite(p,sizeof(struct project),1,file);fclose(file);//关闭文件}else{for(i=j;i<r;i++)//用后边的值覆盖前边的值p[i]=p[i+1];r--;//删除一个,计数的全局变量r自减一for(i=0;i<r;i++,p++)fwrite(p,sizeof(struct project),1,file);//把信息写到文件中去fclose(file);//关闭文件printf("删除成功!");}}void paixu(struct project *p)//进行排序{int i,j,t,sum[10],m;struct project b;FILE *file;if((file=fopen("c:\\project.dat","r"))==NULL)//打开文件{printf("Open error!!\n");getch();exit(0);}for(i=0;i<r;i++){fread(p+i,sizeof(struct project),1,file);//读取信息sum[i]=p[i].sjf+p[i].jingfei; //总项目经费}for(i=0;i<r;i++)//对总项目经费排序{for(j=0;j<=r-i;j++)if(sum[j]<sum[j+1])//把总额和项目信息一并交换{t=sum[j];sum[j]=sum[j+1];sum[j+1]=t;b=p[j];p[j]=p[j+1];p[j+1]=b;}}printf("项目名称项目主持人的姓名性别年龄手机号码项目编号立项时间项目单位项目级别项目期限研究人员下拨经费校配经费经费总额\n");for(m=0;m<r;m++){fread(p+m,sizeof(struct project),1,file);printf("%-14s",p[m].pn);printf("%-15s",p[m].name);printf("%-5c",p[m].sex);printf("%-6d",p[m].age);printf("%-12s",p[m].pnum);printf("%-11s",p[m].pt);printf("%-12s",p[m].time);printf("%-10s",p[m].danwei);printf("%-8s",p[m].pj);printf("%-12s",p[m].qixian);printf("%-13s",p[m].chengyuan);printf("%-10d",p[m].jingfei);printf("%-10d",p[m].sjf);printf("%-10d",sum[m]);printf("\n");}fclose(file); //关闭文件}void caidan(struct project *p)//菜单{int n,t=0,s=0;do{printf("\n\t\t*******************************************************");printf("\n\t\t* 1:输出基本信息*");printf("\n\t\t* 2:输出所需信息*");printf("\n\t\t* 3:排序*");printf("\n\t\t* 4:清屏*");printf("\n\t\t* 0:退出*");printf("\n\t\t* *");printf("\n\t\t********************************************************");printf("\n\n"); fflush(stdin);scanf("%d",&n);if(n==1)shuchu(a);if(n==2)xianshi(a);if(n==3)paixu(a);if(n==4)system("cls");//清屏if(n==0)return;}while(n!=0);//输入为0时退出}void main()//主函数{int w;FILE*fp; //定义文件指针FILE *file; //定义文件指针if((fp=fopen("c:\\num.txt","r"))==NULL)//用于保存全局变量r的值{fp=fopen("c:\\num.txt","wb+");//如果没有文件就见一个}fscanf(fp,"%d",&r);fclose(fp);if((file=fopen("c:\\project.dat","rb+"))==NULL) //用于保存项目结构体的信息{file = fopen("c:\\project.dat", "wb+");}fscanf(file,"%s",a);//把文件中的信息调出来fclose(file);while(1){printf("\n\t\t************************************************************"); printf("\n\t\t* 欢迎使用项目管理系统*"); printf("\n\t\t* *"); printf("\n\t\t* 请选择*"); printf("\n\t\t* 1. 录入项目信息*"); printf("\n\t\t* 2. 查询项目信息*"); printf("\n\t\t* 3. 删除信息*"); printf("\n\t\t* 4. 添加科研信息*"); printf("\n\t\t* 5. 修改信息*"); printf("\n\t\t* 6. 清屏*"); printf("\n\t\t* 0. 退出程序*"); printf("\n\t\t************************************************************"); printf("\n\n");fflush(stdin);scanf("%d",&w);//输入数字进行选择switch(w){case 1:shuru(a);break;case 2:caidan(a);break;case 3:shanchu(a);break;case 4:add(a);break;case 5:xiugai(a);break;case 6: system("cls");break;case 0: //终止程序,保存数据!{if((fp=fopen("c:\\num.txt","w"))==NULL)//用于保存全局变量r的值{printf("error");exit(0);}fprintf(fp,"%d",r);fclose(fp);exit(0);break;if((file=fopen("c:\\project.dat","rb+"))==NULL) //用于保存项目信息{printf("error");exit(0);}fprintf(file,"%s",a);fclose(file);exit(0);break;}default: printf("输入错误,请重新输入!\n");}}}。
c语言课程设计之实验设备管理系统
![c语言课程设计之实验设备管理系统](https://img.taocdn.com/s3/m/4056ee72a26925c52cc5bffd.png)
目录目录.............................................................................................................................-1 - 一设计目的.................................................................................................................-2 - 二课程设计的内容.....................................................................................................-2 - 三课程设计的要求与数据.........................................................................................-2 - 四课程设计应完成的工作.........................................................................................-2 - 五总体设计(包含几大功能模块——流程图).....................................................-2 - 六详细设计(各功能模块的具体实现算法——流程图).....................................-3 -七调试分析(包含各模块的测试用例,及测试结果) (8)八总结.........................................................................................................................-17 - 九成员设计内容 (17)十参考资料.................................................................................................................-17 -一:设计目的练习与巩固《C语言程序设计》)理论知识,通过实践检验和提高实际能力,进一步培养自己综合分析问题和解决问题的能力。
操作系统课程设计 设备管理实现 源代码
![操作系统课程设计 设备管理实现 源代码](https://img.taocdn.com/s3/m/65080af0ccbff121dc368386.png)
#include <stdio.h>#include "iostream.h"#include "stdlib.h"#include "string.h"struct PCB{int id;char name[10];int size;struct PCB *next;};struct PCB *running;struct PCB *ready;struct PCB *blocked;struct PCB *q;struct PCB *p;int id=1;int size;char name[10];////////////////////////////////////////////////////////////////////////////////////// struct DCT{ //设备char name[10];int busy;PCB * occupied;PCB * waiting;struct DCT *next;struct COCT* coct; //上级控制器};struct COCT{ //控制器char name[10];int busy;PCB * occupied;PCB * waiting;struct COCT *next;struct CHCT* chct; //控制器的上级通道};struct CHCT{ //通道char name[10];int busy;PCB * occupied;PCB * waiting;struct CHCT *next;//////////////////////////////////////////////////////////////////////////////////////struct DCT * dcts;struct COCT *cocts;struct CHCT *chcts;void enqueue(int id,char *name,int size,struct PCB *head){ struct PCB *node=(struct PCB *)malloc(sizeof(struct PCB));node->next=0;node->id=id;strcpy(node->name,name);node->size=size;struct PCB *tmp=head;while(tmp->next!=0)tmp=tmp->next;tmp->next=node;}struct PCB * dequeue(struct PCB *head){struct PCB * tmp=head->next;if(head->next!=0){head->next=head->next->next;tmp->next=0;}return(tmp);}void createProcess(){printf("\nname: ");scanf("%s",name);printf("size: ");scanf("%d",&size);printf("\n");enqueue(id++,name,size,ready);if(running==0){running=dequeue(ready);}}void switchProcess(){if(running!=0&&ready->next!=0)enqueue(running->id,running->name,running->size,ready);running=dequeue(ready);}elseprintf("没有可切换的进程\n");}void blockProcess(){if(running==0)printf("没有可阻塞的进程\n");else{enqueue(running->id,running->name,running->size,blocked);running=0;if(ready->next==0)printf("没有可执行的进程\n");elserunning=dequeue(ready);}}void wakeupProcess(){if(blocked->next==0)printf("没有可激活的进程");else{enqueue(blocked->next->id,blocked->next->name,blocked->next->size,ready); dequeue(blocked);if(running==0)running=dequeue(ready);}}void terminateProcess(){ //结束进程if(running==0){printf("没有需要结束的进程\n");}else{running=dequeue(ready);}}void displayProcessstatus(){printf("--------就绪态--------\n");if(ready->next==0)printf("当前没有进程在该状态\n");if(ready->next!=0){q=ready->next;while(ready->next!=0){printf("%s",ready->next->name);printf(" %d\n",ready->next->size);ready->next=ready->next->next;}ready->next=q;}printf("--------执行状态--------\n");if(running==0) printf("当前没有进程在该状态\n");if(running!=0){printf("%s",running->name);printf(" %d\n",running->size);}printf("--------阻塞状态--------\n");if(blocked->next==0) printf("当前没有进程在该状态\n\n");if(blocked->next!=0){p=blocked->next;while(blocked->next!=0){printf("%s",blocked->next->name);printf(" %d\n",blocked->next->size);blocked->next = blocked->next->next;}blocked->next=p;}}//////////////////////////////////////////////////////////////////////////////////struct DCT * findDCT(char name[]) //设备分配时找到要添加的设备{struct DCT *temp = dcts;while(temp->next!=NULL){temp = temp->next;if(strcmp(temp->name,name)==0)return temp;}return NULL;}struct CHCT * findChannel(char name[]){struct CHCT *temp = chcts;while(temp->next!=NULL){temp = temp->next;if(strcmp(temp->name,name)==0)return temp;}return NULL;}struct COCT * findController(char name[]){struct COCT *temp = cocts;while(temp->next!=NULL){temp = temp->next;if(strcmp(temp->name,name)==0)return temp;}return NULL;}void addProcesstoWaiting(struct PCB * waiting,struct PCB *p)//进入进程等待队列{struct PCB *temp = waiting;while(temp->next!=NULL){temp = temp->next;}//temp->next = p;//+++++++++++++++++++++++++++++++++++++++++++++++++temp->next = new struct PCB;temp->next->id = p->id;strcpy(temp->next->name,p->name);temp->next->size = p->size;temp->next->next = NULL;//++++++++++++++++++++++++++++++++++++++++++++++++++ }void add(struct PCB * head,struct PCB * node){ //入队列struct PCB *tmp=head;while(tmp->next!=0)tmp=tmp->next;tmp->next=node;}struct PCB * getFirst(struct PCB *head){ //获得队列里的第一个进程return head->next;}void allocateCHCT(struct CHCT* chct,PCB *p)//分配CHCT{if(chct->occupied!=0){printf("不能分配通道\n");addProcesstoWaiting(chct->waiting,p);}else{chct->occupied=p;printf("分配成功!\n");}add(blocked,p);if(ready!=0)running=dequeue(ready);elserunning=0;}//**************************************************void allocateCOCT(struct COCT* coct,PCB *p){if(coct->occupied!=0){printf("不能分配控制器\n");addProcesstoWaiting(coct->waiting,p);add(blocked,p);if(ready!=0)running=dequeue(ready);elserunning=0;return;}else{coct->occupied=p;allocateCHCT(coct->chct,p);}}void allocateDCT(){char nameDCT[10];printf("请输入设备名称:");scanf("%s",nameDCT);struct DCT * dct=findDCT(nameDCT); struct PCB * p = running;if(dct!=NULL&&p!=NULL){if(dct->occupied!=0){printf("不能分配设备\n"); addProcesstoWaiting(dct->waiting,p); add(blocked,p);if(ready!=0)running=dequeue(ready);elserunning=0;return;}else{dct->occupied=p;allocateCOCT(dct->coct,p);//++++++++++++++++++++++++++++ /*add(blocked,p);if(ready!=0)running=dequeue(ready);elserunning=0;return;*///+++++++++++++++++++++++++++++ }}elseprintf("发生错误!\n");}void releaseCHCT(char *name,struct CHCT* chct,struct PCB* p) //?????? {if(p!=NULL)addProcesstoWaiting(chct->waiting,p);if(strcmp(name,chct->occupied->name)==0){if(chct->waiting->next!=NULL){chct->occupied = dequeue(chct->waiting);}else{chct->occupied = NULL;}}}void releaseCOCT(char *name,struct COCT* coct,struct PCB* p){if(p!=NULL)addProcesstoWaiting(coct->waiting,p);if(strcmp(name,coct->occupied->name)==0){if(coct->waiting->next!=NULL){coct->occupied = dequeue(coct->waiting);}else{coct->occupied = NULL;}releaseCHCT(name,coct->chct,coct->occupied);}}void releaseDCT(){char nameDCT[10];printf("请输入要释放的设备名称:\n");scanf("%s",nameDCT);char nameP[10];printf("请输入要释放的进程名称:\n");scanf("%s",nameP);struct DCT *temp = findDCT(nameDCT);if(strcmp(temp->occupied->name,nameP)==0){if(temp->waiting->next!=NULL){temp->occupied = dequeue(temp->waiting);}else{temp->occupied = NULL;}releaseCOCT(nameP,temp->coct,temp->occupied);}else{printf("没有对应的设备和进程!");}}void addChannel(char name[]){struct CHCT * temp=(struct CHCT *)malloc(sizeof(struct CHCT));strcpy(temp->name,name);temp->next=0;temp->busy=0;temp->waiting = new struct PCB;temp->waiting->next = NULL;//temp->waiting=0;temp->occupied=0;struct CHCT * head=chcts; //进入了chcts队列while(head->next!=0)head=head->next;head->next=temp;}void addController(char *name,struct CHCT * chct){ //增加控制器struct COCT * temp=(struct COCT *)malloc(sizeof(struct COCT));strcpy(temp->name,name);temp->next=0;temp->busy=0;temp->waiting = new struct PCB;temp->waiting->next = NULL;//temp->waiting=0; //+temp->occupied=0;temp->chct= chct;struct COCT * head=cocts; //进入了cocts队列while(head->next!=0)head=head->next;head->next=temp;}void addDevice(char *name,struct COCT * coct){ //增加设备struct DCT * temp=(struct DCT *)malloc(sizeof(struct DCT));strcpy(temp->name,name);temp->next=0;temp->busy=0;temp->waiting = new struct PCB;temp->waiting->next = NULL;//temp->waiting=0;temp->occupied=0;temp->coct= coct;struct DCT * head=dcts;while(head->next!=0)head=head->next;head->next=temp;}//添加设备++++++++++++++++++++++++++++++++++void add_dct(){char newDCT[10];printf("请输入新设备的名字:\n");scanf("%s",newDCT);char newCOCT[10];printf("请输入要添加到的控制器的名字:\n");scanf("%s",newCOCT);addDevice(newDCT,findController(newCOCT));}//添加控制器void add_coct(){char newCOCT[10];printf("请输入新控制器的名字:\n");scanf("%s",newCOCT);char newCHCT[10];printf("请输入要添加到的通道的名字:\n");scanf("%s",newCHCT);addController(newCOCT,findChannel(newCHCT));}//添加通道void add_chct(){char newCHCT[10];printf("请输入新的通道的名字:\n");scanf("%s",newCHCT);addChannel(newCHCT);}//++++++++++++++++++++++++++++++++++//+++++++++++++++++删除操作++++++++++++++++++++ //删除设备void deleteDCT(char nameDCT[]){//char nameDCT[10];//int i=0;//printf("请输入要删除DCT的名字:");//scanf("%s",nameDCT);struct DCT * temp = findDCT(nameDCT);struct DCT * head = dcts;if(temp==NULL){printf("没有对应的设备!\n");return ;}elsewhile(head->next!=0){if(strcmp(temp->name,head->next->name)==0){if(temp->occupied!=NULL)printf("此设备现在正在使用不能删除\n");elsehead->next=head->next->next;//i++;break;}elsehead=head->next;}}//删除控制器void deleteCOCT(char nameCOCT[]){struct COCT *temp=findController(nameCOCT);struct COCT *head=cocts;if(temp==NULL){printf("没有对应的控制器\n");return;}elsewhile(head->next!=0){if(strcmp(temp->name,head->next->name)==0){if(temp->occupied!=NULL)printf("此控制器现在正在使用不能删除\n");else{//deleteDCT(temp->);head->next=head->next->next;}break;}head=head->next;}}//删除通道void deleteCHCT(char nameCHCT[]){struct CHCT *temp=findChannel(nameCHCT);struct CHCT *head=chcts;if(temp==NULL){printf("没有对应的通道\n");return;}elsewhile(head->next!=0){if(strcmp(temp->name,head->next->name)==0){if(temp->occupied!=NULL)printf("此通道现在正在使用不能删除\n");else{//deleteDCT(temp->);head->next=head->next->next;}//i++;break;}head=head->next;}}//+++++++++++++++++++++++++++++++++++++++++++void displayDCT(){struct DCT * dct;struct COCT *coct;struct CHCT *chct = chcts;struct PCB *pcb;//------------------------------while(chct->next!=NULL){chct = chct->next;printf(" %s(",chct->name);if(chct->occupied!=0)printf("%s",chct->occupied->name);printf(")");pcb = chct->waiting->next;//waiting是头结点,pcb指向队列第一个进程while(pcb!=NULL){printf("[%s]",pcb->name);pcb = pcb->next;}printf("\n");//----------------------------------------------------coct = cocts;while(coct->next!=NULL){coct = coct->next;if(strcmp(coct->chct->name,chct->name)==0){printf(" %s(",coct->name);if(coct->occupied!=0)printf("%s",coct->occupied->name);printf(")");pcb = coct->waiting->next;while(pcb!=NULL){printf("[%s]",pcb->name);pcb = pcb->next;}printf("\n");//-----------------------------------------dct = dcts;while(dct->next!=NULL){dct = dct->next;if(strcmp(dct->coct->name,coct->name)==0){printf(" %s(",dct->name);if(dct->occupied!=0)printf("%s",dct->occupied->name);printf(")");pcb = dct->waiting->next;while(pcb!=NULL){printf("[%s]",pcb->name);pcb = pcb->next;}printf("\n");}}}}}}//////////////////////////////////////////////////////////////////////void main(){dcts=(struct DCT *)malloc(sizeof(struct DCT));dcts->next=0;cocts=(struct COCT *)malloc(sizeof(struct COCT));cocts->next=0;chcts=(struct CHCT *)malloc(sizeof(struct CHCT));chcts->next=0;addChannel("chct1");addChannel("chct2");addController("coct1",findChannel("chct1"));addController("coct2",findChannel("chct1"));addController("coct3",findChannel("chct2"));addDevice("dct1",findController("coct1"));addDevice("dct2",findController("coct1"));addDevice("dct3",findController("coct2"));//addDevice("dct4",findController("coct2"));addDevice("dct4",findController("coct3"));ready=(struct PCB *)malloc(sizeof(struct PCB));blocked=(struct PCB *)malloc(sizeof(struct PCB));ready->next=0;blocked->next=0;A:while(1){int choice;int function;printf("1:创建进程\n");printf("2:切换进程\n");printf("3:阻塞进程\n");printf("4:唤醒进程\n");printf("5:结束进程\n");printf("6:显示进程\n");printf("7:设备管理\n");printf("0:exit\n");scanf("%d",&choice);switch(choice){case 1:createProcess();break;case 2:switchProcess();break; case 3:blockProcess();break;case 4:wakeupProcess();break; case 5:terminateProcess();break; case 6:displayProcessstatus();break; case 7:while(1){printf("1:设备分配\n");printf("2:设备释放\n");printf("3:显示\n");printf("4:添加新的设备\n");printf("5:添加新的控制器\n"); printf("6:添加新的通道\n");printf("7:删除设备\n");printf("8:删除控制器\n");printf("9:删除通道\n");printf("0:返回主界面\n");scanf("%d",&function);switch(function){case 1:allocateDCT();break;case 2:releaseDCT();break;case 3:displayDCT();break;case 4:add_dct();break;case 5:add_coct();break;case 6: add_chct();break;case 7:char nameDCT[10];printf("请输入要删除DCT的名字:\n");scanf("%s",nameDCT);deleteDCT(nameDCT);break; case 8:char nameCOCT[10];printf("请输入要删除COCT的名字:\n");scanf("%s",nameCOCT);deleteCOCT(nameCOCT);break;case 9:char nameCHCT[10];printf("请输入要删除CHCT的名字:\n");scanf("%s",nameCHCT);deleteCHCT(nameCHCT);break;case 0:goto A;break;}}case 0:exit(0);break;}}}。
C语言 实验室设备管理系统
![C语言 实验室设备管理系统](https://img.taocdn.com/s3/m/71511a0010a6f524ccbf85d6.png)
整个系统可设计为实验设备信息输入模块 实验设备信息添加模块 实验设备信息修改模 块 实验设备分类统计模块和实验设备查询模块。
实验设备管理系统设计
实验 设备 信息 输入 模块
实验 设备 信息 添加 模块
实验 设备 信息 修改 模块
实验 设备 分内 统计 模块
实验 设备 查询 模块
(5) 查询记录 若信息为空,则不能查询。流程图如下: 开始
判断是否有资料为空 资料为空 跳出 输入要查询的分类序号 按输入序号调用各功能模块 函数
结束
4
(6)结束语
通过本次 c 语言的程序设计,我不仅提高巩固了 c 语言的基础,也初学习了编写一个实 用程序的流程,提高了动手操作能力,也提高了对编程的兴趣。我相信经过努力后,我的编 程能力一定会得到提高。
C 语言程序设计报告
1 课程设计题目:实验室设备管理里系统
实验设备信息包括:设备编号、设备种类(如:微机 打印机 扫描仪 等等)、设备名称、 设备价格、设备购入日期、是否报废、报废日期等。试设计一实验设备信息管理系统,使之 能提供以下功能: (1)能够完成对设备的录入和修改 (2)对设备进行分类统计 (3)设备的查询
开始
输入 ID 号,并将指针指向最 末尾
依次输入设备机构体内容, 完成一条添加 Nhomakorabea录提示一完成一条记录添加
结束
2
(2) 修改记录 系统要求用户输入要修改的设备 ID 号,这时系统会显示设备的具体信息, 用户只需该设备新的信息按要求输入即可对信息进行修改。流程图如下: 开始 判断是否有资料可以统计分 类 没有资料可以统计 跳出 输入要统计的分类序号 按输入序号调用各功能模块 函数 结束
操作系统设备管理实验代码
![操作系统设备管理实验代码](https://img.taocdn.com/s3/m/f804190403d8ce2f00662396.png)
#include<iostream>using namespace std;//typedef struct node{char name[10];char devname[10];struct node *next;}PCB;//进程PCB * run;//执行队列//typedef struct Node{char identify[10];//标识int state;//设备状态PCB *blocking;//阻塞队列指针}CHCT;//通道控制表CHCT * CH1, * CH2;//typedef struct NOde{char identify[10];//标识int state;//设备状态CHCT * chct;//CHCTPCB *blocking;//阻塞队列指针struct NOde *next;}COCT;//控制器控制表COCT * cohead;typedef struct NODe{char identify[10];//标识char type;//设备类型int state;//设备状态int times;//重复执行次数PCB *blocking;//阻塞队列指针COCT * coct;//COCT}DCT;//设备控制表typedef struct NODE{char type;//类别char identify[10];//标识DCT * dct;//DCT//驱动入口地址struct NODE *next;}SDT;//系统设备表SDT * head;SDT * checkdel;void Init(){PCB * ch1block,* ch2block,* co1block,* co2block,* co3block,* d1block,* d2block,* d3block,* d4block;COCT * CO1,* CO2,* CO3;DCT *d1,*d2,*d3,*d4;SDT *s1,*s2,*s3,*s4;//=================================================run=(PCB *)malloc(sizeof(PCB));run->next=NULL;CH1=(CHCT *)malloc(sizeof(CHCT));CH2=(CHCT *)malloc(sizeof(CHCT));strcpy(CH1->identify,"ch1");strcpy(CH2->identify,"ch2");CH1->state=0;CH2->state=0;ch1block=(PCB *)malloc(sizeof(PCB));ch1block->next=NULL;ch2block=(PCB *)malloc(sizeof(PCB));ch2block->next=NULL;CH1->blocking=ch1block;CH2->blocking=ch2block;cohead=(COCT *)malloc(sizeof(COCT));cohead->next=NULL;CO1=(COCT *)malloc(sizeof(COCT));cohead->next=CO1;CO1->next=NULL;CO2=(COCT *)malloc(sizeof(COCT));CO1->next=CO2;CO2->next=NULL;CO3=(COCT *)malloc(sizeof(COCT));CO2->next=CO3;CO3->next=NULL;CO1->state=0;CO2->state=0;CO3->state=0;co1block=(PCB *)malloc(sizeof(PCB));co1block->next=NULL;co2block=(PCB *)malloc(sizeof(PCB));co2block->next=NULL;co3block=(PCB *)malloc(sizeof(PCB));co3block->next=NULL;strcpy(CO1->identify,"co1");strcpy(CO2->identify,"co2");strcpy(CO3->identify,"co3");CO1->chct=CH1;CO2->chct=CH1;CO3->chct=CH2;CO1->blocking=co1block;CO2->blocking=co2block;CO3->blocking=co3block;//===================================================== d1block=(PCB *)malloc(sizeof(PCB));d2block=(PCB *)malloc(sizeof(PCB));d3block=(PCB *)malloc(sizeof(PCB));d4block=(PCB *)malloc(sizeof(PCB));d1block->next=NULL;d2block->next=NULL;d3block->next=NULL;d4block->next=NULL;d1=(DCT *)malloc(sizeof(DCT));strcpy(d1->identify,"P");d2=(DCT *)malloc(sizeof(DCT));strcpy(d2->identify,"T");d3=(DCT *)malloc(sizeof(DCT));strcpy(d3->identify,"K");d4=(DCT *)malloc(sizeof(DCT));strcpy(d4->identify,"M");d1->coct=CO1;d2->coct=CO2;d3->coct=CO3;d4->coct=CO3;d1->state=0;d2->state=0;d3->state=0;d4->state=0;d1->type='o';d2->type='o';d3->type='i';d4->type='i';d1->blocking=d1block;d2->blocking=d2block;d3->blocking=d3block;d4->blocking=d4block;//================================head=(SDT *)malloc(sizeof(SDT));head->next=NULL;s1=(SDT *)malloc(sizeof(SDT));s2=(SDT *)malloc(sizeof(SDT));s3=(SDT *)malloc(sizeof(SDT));s4=(SDT *)malloc(sizeof(SDT));head->next=s1;s1->next=s2;s2->next=s3;s3->next=s4;s4->next=NULL;s1->dct=d1;s2->dct=d2;s3->dct=d3;s4->dct=d4;strcpy(s1->identify,"P");strcpy(s2->identify,"T");strcpy(s3->identify,"K");strcpy(s4->identify,"M");s1->type='o';s2->type='o';s3->type='i';s4->type='i';//testSDT *temp=head->next;}//============================================ //添加设备时候,添加新控制器,把控制器加到最后void Addcotrol (COCT *temp){COCT *cotemp=cohead;while(cotemp->next!=NULL){cotemp=cotemp->next;}cotemp->next=temp;temp->next=NULL;}//查看所有控制器,选择所要连接的控制器void Showallco(){COCT *temp=cohead->next;while(temp!=NULL){cout<<temp->identify<<" ";temp=temp->next;}cout<<endl;}//查找要连接的控制器COCT * Findco(char a[]){COCT * temp=cohead->next;while(temp!=NULL){if(!strcmp(temp->identify,a)){return temp;}temp=temp->next;}return temp;}//删除设备时候,判断是不是同时删除控制器,等于1删,0不删int sf_deleteco(char a[],char b[]){SDT *temp;temp=head->next;while(temp!=NULL){if((strcmp(temp->identify,a))&&((!strcmp(temp->dct->coct->identify,b)))) {return 0;}temp=temp->next;}return 1;}//删除设备的时候同时删除控制器void Deletecotrol(COCT *te){COCT * temp=cohead;while(temp->next!=te){temp=temp->next;}temp->next=te->next;delete(te);}//添加设备,查找设备是不是已经存在int sf_exist(char a[]){SDT *temp;if(head->next==NULL){return 0;}else{temp=head->next;while(temp!=NULL){if(!strcmp(a,temp->identify)){checkdel=temp;return 1;}temp=temp->next;}return 0;}}//申请设备时候,如果忙,将设备挂到等待队列void Addwaitpcb(PCB * p1,PCB * p2){PCB *temp=p1;while(temp->next!=NULL){temp=temp->next;}temp->next=p2;p2->next=NULL;}//回收设备时候,对PCB的操作void Deletepcb(char a[]){PCB * temp2=run->next,* temp=run;while(temp2!=NULL){if(!strcmp(temp2->devname,a)){temp->next=temp2->next;delete(temp2);break;}temp=temp2;temp2=temp->next;}}//判断等待队列是不是空int sf_pcbnull(PCB *temp){if(temp->next==NULL){return 0;}else return 1;}//查看所有设备状态void Showmenu(){PCB * ptemp=run->next;SDT * temp=head->next;DCT * dtemp;COCT * cotemp;CHCT * chtemp;cout<<"SDT"<<" i/o"<<" COCT"<<" CHCT"<<endl;while(temp!=NULL){dtemp=temp->dct;cotemp=dtemp->coct;chtemp=cotemp->chct;cout<<dtemp->identify<<"["<<dtemp->state<<"]"<<"\t"<<dtemp->type<<"\t"<<cote mp->identify<<"["<<cotemp->state<<"]"<<"\t"<<chtemp->identify<<"["<<chtemp->state<<"]"<<endl;temp=temp->next;}while(ptemp!=NULL){cout<<"进程"<<ptemp->name<<"申请了设备"<<ptemp->devname<<endl;ptemp=ptemp->next;}cout<<endl;}//设备独立性时候查找要查找的类型是不是存在int sf_typeexist(char ch){SDT *temp;if(head->next==NULL){return 0;}else{temp=head->next;while(temp!=NULL){if(temp->type==ch){return 1;}else temp=temp->next;}}return 0;}//增加设备void Adddevice(){cout<<"增加设备"<<endl;SDT * stemp,* s2temp;COCT *cotemp;DCT *temp;char temptype;PCB *tempblock,* cotempblock;char choice;char eqary[10],coary[10];cin>>eqary;//此处查找SDT,看是否所要添加的设备已经存在if(sf_exist(eqary)==1){//设备已经存在cout<<"设备已存在"<<endl;}else{//设备不存在tempblock=(PCB *)malloc(sizeof(PCB));tempblock->next=NULL;temp=(DCT *)malloc(sizeof(DCT));strcpy(temp->identify,eqary);temp->blocking=tempblock;temp->state=0;cout<<"输入设备类型"<<endl;cin>>temptype;temp->type=temptype;stemp=(SDT *)malloc(sizeof(SDT));stemp->next=NULL;stemp->dct=temp;stemp->type=temptype;strcpy(stemp->identify,eqary);s2temp=head;while(s2temp->next!=NULL){s2temp=s2temp->next;}s2temp->next=stemp;stemp->next=NULL;cout<<"是否添加控制器?(y/n)"<<endl;cin>>choice;if((choice=='y')||(choice=='Y')){ //添加新控制器cout<<"输入控制器名称:"<<endl;cin>>coary;cotempblock=(PCB *)malloc(sizeof(PCB));cotempblock->next=NULL;cotemp=(COCT *)malloc(sizeof(COCT));cotemp->next=NULL;strcpy(cotemp->identify,coary);cotemp->state=0;cotemp->blocking=cotempblock;Addcotrol(cotemp);temp->coct=cotemp;cout<<"请选择连接的通道:1/2"<<endl;int i;cin>>i;if(i==1){cotemp->chct=CH1;}else{cotemp->chct=CH2;}}else{//不添加控制器Showallco();cout<<"输入连接控制器的名称:"<<endl;cin>>coary;cotemp=Findco(coary);temp->coct=cotemp;}cout<<"设备"<<eqary<<"添加成功!"<<endl;}}//删除设备void Deletedevice(){//删除设备的时候同时删除pcb Deletepcbcout<<"删除设备"<<endl;COCT * temp;SDT * stemp;char chary[10];char tempary[10];cin>>chary;if(sf_exist(chary)==0){cout<<"删除设备不存在!"<<endl;}else if(checkdel->dct->state==1){cout<<"设备正在使用无法删除"<<endl;}else{//sf_deleteco();Deletepcb(chary);strcpy(tempary,checkdel->dct->coct->identify);if(sf_deleteco(chary,tempary)){//删除控制器temp=checkdel->dct->coct;Deletecotrol(temp);}stemp=head;while(stemp->next!=checkdel){stemp=stemp->next;}stemp->next=checkdel->next;delete(checkdel);cout<<"设备"<<chary<<"删除成功!"<<endl;}}//申请设备void Applydevice(){cout<<"申请设备"<<endl;PCB *ptemp;DCT *dtemp;COCT *cotemp;CHCT *chtemp;char pname[10],eqname[10];cin>>pname>>eqname;if(sf_exist(eqname)==0){cout<<"设备不存在!"<<endl;}else{//checkdel(对应要申请设备的指针)ptemp=(PCB *)malloc(sizeof(PCB));strcpy(ptemp->name,pname);ptemp->next=NULL;dtemp=checkdel->dct;//====================此处是否要考虑状态的改变========================if(dtemp->state==1){//设备忙Addwaitpcb(dtemp->blocking,ptemp);cout<<"进程"<<ptemp->name<<"被挂在设备"<<dtemp->identify<<"的等待队列上!"<<endl;}else{//设备不忙cotemp=dtemp->coct;if(cotemp->state==1){//控制器忙Addwaitpcb(cotemp->blocking,ptemp);cout<<"进程"<<ptemp->name<<"被挂在控制器"<<cotemp->identify<<"的等待队列上!"<<endl;}else{//控制器不忙chtemp=cotemp->chct;if(chtemp->state==1){//通道忙Addwaitpcb(chtemp->blocking,ptemp);cout<<"进程"<<ptemp->name<<"被挂在通道"<<chtemp->identify<<"的等待队列上!"<<endl;}else{//通道不忙Addwaitpcb(run,ptemp);dtemp->state=1;cotemp->state=1;chtemp->state=1;strcpy(ptemp->devname,eqname);cout<<"进程"<<pname<<"申请设备"<<eqname<<"成功!"<<endl;}}}}}//回收设备void Recycledevice(){cout<<"回收设备"<<endl;// char ch;char eqname[10];DCT *dtemp;COCT *cotemp;CHCT *chtemp;PCB *pctemp1,*pctemp2;cin>>eqname;if(sf_exist(eqname)==0){//设备不存在cout<<"要回收的设备不存在!"<<endl;}else if(checkdel->dct->state==0){//设备存在,但是不需要回收cout<<"设备处于闲状态,不需要回收!"<<endl;}else{//需要回收Deletepcb(eqname);//dtemp=checkdel->dct;cotemp=dtemp->coct;chtemp=cotemp->chct;dtemp->state=0;cotemp->state=0;chtemp->state=0;if(sf_pcbnull(chtemp->blocking)){//如果通道等待队列不空pctemp1=chtemp->blocking;pctemp2=pctemp1->next;pctemp1->next=pctemp2->next;pctemp2->next=NULL;strcpy(pctemp2->devname,eqname);Addwaitpcb(run,pctemp2);dtemp->state=1;cotemp->state=1;chtemp->state=1;}else{if(sf_pcbnull(cotemp->blocking)){//如果控制器的等待队列不空pctemp1=cotemp->blocking;pctemp2=pctemp1->next;pctemp1->next=pctemp2->next;pctemp2->next=NULL;strcpy(pctemp2->devname,eqname);Addwaitpcb(run,pctemp2);dtemp->state=1;cotemp->state=1;chtemp->state=1;}else{if(sf_pcbnull(dtemp->blocking)){//如果设备的等待队列不空pctemp1=dtemp->blocking;pctemp2=pctemp1->next;pctemp1->next=pctemp2->next;pctemp2->next=NULL;strcpy(pctemp2->devname,eqname);Addwaitpcb(run,pctemp2);dtemp->state=1;cotemp->state=1;chtemp->state=1;}}}cout<<"设备"<<eqname<<"回收成功!"<<endl;}}//设备独立性=======void Independence(){cout<<"设备独立性--申请设备:"<<endl;//cout<<"申请设备"<<endl;char type;char pname[10];SDT * temp,* temp2;PCB *ptemp;DCT *dtemp;COCT *cotemp;CHCT *chtemp;cin>>pname>>type;if((type=='o')||(type=='i')){//=========还得考虑要申请的类型是不是存在============================ if(sf_typeexist(type)==0){cout<<"要申请的该类设备不存在!"<<endl;}else{temp=head->next;while(temp!=NULL){if((temp->type==type)&&(temp->dct->state==0)){//当设备类型相同,并且设备空闲temp2=temp;break;}else if((temp->type==type)){temp2=temp;}temp=temp->next;}sf_exist(temp2->identify);//================================================ =ptemp=(PCB *)malloc(sizeof(PCB));strcpy(ptemp->name,pname);ptemp->next=NULL;dtemp=checkdel->dct;//要用了这个函数才可以========================================================================== if(temp2->dct->state==0){//当设备不忙时候cotemp=dtemp->coct;if(cotemp->state==1){//控制器忙Addwaitpcb(cotemp->blocking,ptemp);cout<<"进程"<<ptemp->name<<"被挂在控制器"<<cotemp->identify<<"的等待队列上!"<<endl;}else{//控制器不忙chtemp=cotemp->chct;if(chtemp->state==1){//通道忙Addwaitpcb(chtemp->blocking,ptemp);cout<<"进程"<<ptemp->name<<"被挂在通道"<<chtemp->identify<<"的等待队列上!"<<endl;}else{//通道不忙Addwaitpcb(run,ptemp);dtemp->state=1;cotemp->state=1;chtemp->state=1;strcpy(ptemp->devname,temp2->identify);cout<<"进程"<<pname<<"申请设备"<<temp2->identify<<"成功!"<<endl;}}}else{//当设备忙时候Addwaitpcb(dtemp->blocking,ptemp);cout<<"进程"<<ptemp->name<<"被挂在设备"<<dtemp->identify<<"的等待队列上!"<<endl;}}}else{cout<<"输入设备的类型错误!"<<endl;}}//void Show(){cout<<"A :增加设备"<<endl;cout<<"D :删除设备"<<endl;cout<<"S :申请设备"<<endl;cout<<"H :回收设备"<<endl;cout<<"I :设备独立性"<<endl;cout<<"Q :退出"<<endl;}//int main(){ cout<<" 操作系统实验三 "<<endl; cout<<" "<<endl; cout<<"相关指令:"<<endl;Init();Show();char choice;while(true){Showmenu();cout<<"选择指令:"<<endl;cin>>choice;switch(choice){case 'a':case 'A':Adddevice();break;case 'd':case 'D':Deletedevice();break;case 's':case 'S':Applydevice();break;case 'h':case 'H':Recycledevice();break;case 'q':case 'Q':exit(0);case 'i':case 'I':Independence();break;default :cout<<"指令错误"<<endl;break;}}return 0;}。
实验室管理系统源代码及图片
![实验室管理系统源代码及图片](https://img.taocdn.com/s3/m/b50491f76bd97f192279e9ff.png)
#include "graphics.h" // 就是需要引用这个图形库#include<stdio.h>#include<string.h>void welcome(); //欢迎界面void login(); //登陆界面void logingly(); //管理员登陆界面void loginuser(); //学生登录界面void reggly();//管理员注册界面void reguser();//用户注册界面void regok();//注册成功页面void password();//修改密码界面void passwordok();//修改密码成功页面void manner();//管理员界面void usermanner();//用户管理界面void userinfo();//用户信息界面void del(); //删除用户界面void mannerS();//设备管理界面void add();//设备添加界面void find();//设备查询界面void findjg();//查询设备结果void delequ();//删除设备界面void change();//修改界面void user();//用户界面void report();//上报信息界面void findreport();//上报信息显示界面void about();//关于我们界面void help();//帮助界面void thank();//退出界面int save();//文件保存int load();//文件读取struct Equipt //结构体(设备信息){char equiptname[20];//设备名称char equiptnumber[20];//设备编号char price[20];//设备价格char buytime[20] ;//购买时间char location[20];//所在位置char condition[20];//设备状态char staff[20];//操作人员char number[20];//联系方式char usetime[20];//操作时间};Equipt Et[100];struct Report//结构体(上报信息){char roomnumber[20];//教室编号char equiptname[20];//设备名称char fault[20];//故障现象char reporter[20];//上报人员char number[20];//联系方式char reporttime[20];//上报时间} ;Report Rt[100];struct User//结构体{char username[30];//用户名char bianhao[30];//编号char number[30];//联系方式};User ur[100];char username[50]; //用户名char userpassword[50];//密码char glyname[50];//管理员账户char glypassword[50];//管理员密码char* inputstring(int x,int y){PIMAGE img = newimage();setbkmode(TRANSPARENT);getimage(img,x,y-20,200,50);char str[20];char c;int i=0;setcolor(0x3FA61F);setfont(26,0,"宋体");while(1){c=getch();if(c==27) //ESC{return "#ESC";}else if(i>0&&c=='\b'){i--;str[i]='\0';putimage(x,y-20,img,PATCOPY);putimage(x,y-20,img,SRCCOPY);outtextxy(x,y,str);}else if(c!='\r'){str[i++]=c;str[i]='\0';outtextxy(x,y,str);}elsereturn str;}}int main(){setinitmode(0);//去掉启动动画initgraph(690,500); // 初始化,显示一个窗口,这里和TC 略有区别welcome();return 0;}void welcome()//欢迎界面{PIMAGE welcomeing=newimage();//定义变量getimage(welcomeing,"image/welcome.jpg");//获取图片数据putimage(0,0,welcomeing);//图片显示在屏幕窗体上char key=getch();switch(key){case'0':exit(0);break;default:login();break;}return ;}void login()//登陆界面{PIMAGE logining=newimage();//定义变量getimage(logining,"image/login.jpg");//获取图片数据putimage(0,0,logining);//图片显示在屏幕窗体上char key=getch();switch(key){case'1':logingly();break;case'2':loginuser();break;case 27: save();exit(0);}return ;}void logingly()//管理员登陆界面{PIMAGE loginglying=newimage();//定义变量getimage(loginglying,"image/login1.jpg");//获取图片数据while(1){putimage(0,0,loginglying);strcpy(glyname,inputstring(410,115));strcpy(glypassword,inputstring(410,160));if(strcmp(glyname,"guanliyuan")==0&&strcmp(glypassword,"123456")==0) {manner();}else{outtextxy(420,340,"用户名或密码错误");}char key=getch();switch(key){case'2':reggly();break;case'3':password();break;case'4':about();break;case'5':help();break;}}return ;}void loginuser()//用户登录界面{PIMAGE loginusering=newimage();//定义变量getimage(loginusering,"image/login1.jpg");//获取图片数据while(1){putimage(0,0,loginusering);strcpy(username,inputstring(410,115));strcpy(userpassword,inputstring(410,160));if(strcmp(username,"user")==0&&strcmp(userpassword,"123456")==0) {user();}else{outtextxy(420,340,"用户名或密码错误");}char key=getch();switch(key){case'2':reggly();break;case'3':password();break;case'4':about();break;case'5':help();break;}}return ;}void reggly()//管理员注册界面{PIMAGE regglying=newimage();//定义变量getimage(regglying,"image/reg.jpg");//获取图片数据while(1){putimage(0,0,regglying);strcpy(glyname,inputstring(175,74));if(strcmp(glyname,"#ESC")==0)return ;strcpy(glypassword,inputstring(175,140));if(strcmp(glypassword,"#ESC")==0)return ;strcpy(glypassword,inputstring(175,197));if(strcmp(glypassword,"#ESC")==0)return ;strcpy(glypassword,inputstring(175,267));if(strcmp(glypassword,"#ESC")==0)return ;strcpy(glypassword,inputstring(175,333));if(strcmp(glyname,"#ESC")==0)return ;regok();}return ;}void reguser()//注册界面{PIMAGE regusering=newimage();//定义变量getimage(regusering,"image/reg.jpg");//获取图片数据while(1){putimage(0,0,regusering);strcpy(username,inputstring(175,74));if(strcmp(username,"#ESC")==0)return ;strcpy(userpassword,inputstring(175,140));if(strcmp(userpassword,"#ESC")==0)return ;strcpy(userpassword,inputstring(175,197));if(strcmp(userpassword,"#ESC")==0)return ;strcpy(userpassword,inputstring(175,267));if(strcmp(userpassword,"#ESC")==0)return ;strcpy(userpassword,inputstring(175,333));if(strcmp(username,"#ESC")==0)return ;regok();}return ;}void regok()//注册成功页面{PIMAGE regoking=newimage();//定义变量getimage(regoking,"image/regok.jpg");//获取图片数据putimage(0,0,regoking);//图片显示在屏幕窗体上getch();login();return ;}void password()//修改密码页面{PIMAGE passwording=newimage();//定义变量getimage(passwording,"image/password.jpg");//获取图片数据while(1){putimage(0,0,passwording);//图片显示在屏幕窗体上strcpy(userpassword,inputstring(221,121 ));if(strcmp(userpassword,"#ESC")==0)return ;strcpy(userpassword,inputstring(221,123));if(strcmp(userpassword,"#ESC")==0)return ;strcpy(userpassword,inputstring(221,188));if(strcmp(userpassword,"#ESC")==0)return ;strcpy(userpassword,inputstring(221,252));if(strcmp(userpassword,"#ESC")==0)return ;strcpy(userpassword,inputstring(221,317));if(strcmp(userpassword,"#ESC")==0)return ;passwordok();}return ;}void passwordok()//修改密码成功页面{PIMAGE passwordoking=newimage();//定义变量getimage(passwordoking,"image/passwordok.png");//获取图片数据putimage(0,0,passwordoking);//图片显示在屏幕窗体上getch();login();return ;}void manner()//管理员界面{PIMAGE mannering=newimage();//定义变量getimage(mannering,"image/manner.png");//获取图片数据putimage(0,0,mannering);//图片显示在屏幕窗体上char key=getch();switch(key){case'1':mannerS();break;case'2':usermanner();break;case'3':findreport();break;case'0':login();}return ;}void usermanner()//用户管理界面{PIMAGE usermannering=newimage();//定义变量getimage(usermannering,"image/usermanner.png");//获取图片数据while(1){putimage(0,0,usermannering);//图片显示在屏幕窗体上char c=getch();switch(c){case'1':del();break;case'2':userinfo();break;case'0':manner();}}}void userinfo()//用户信息界面{PIMAGE userinfoing=newimage();//定义变量getimage(userinfoing,"image/userinfo.jpg");//获取图片数据putimage(0,0,userinfoing);//图片显示在屏幕窗体上char username[20]={'u','s','e','r'};printf("%s",username);char bianhao[20]={'1'};char number[20]={'1','2','3','4','5','6'};while(1){for(int i=0;i<1;i++){if(strlen(bianhao)>0){outtextxy(124,184+40*i,bianhao);outtextxy(248,184+40*i,username);outtextxy(406,184+40*i,number);}}char key=getch();switch(key){case 27:user();break ;}}return;}void del()//删除用户界面{cleardevice();//清屏PIMAGE deling=newimage();//定义变量getimage(deling,"image/del.jpg");//获取图片数据putimage(0,0,deling);char bianhao[20];strcpy(bianhao,inputstring(170,203));for(int i=0;i<100;i++){if(strcmp(bianhao,ur[i].bianhao)==0)for(int j=i+1;j<100-i;j++)Et[i]=Et[j];}outtextxy(100,450, "删除成功");//设置位置char c=ege::getch();switch(c){case 27:usermanner();break;}return ;}void mannerS()//设备管理界面{PIMAGE mannerSing=newimage();//定义变量getimage(mannerSing,"image/mannerS.png");//获取图片数据while(1){putimage(0,0,mannerSing);//图片显示在屏幕窗体上char bb[10];char c=getch();switch(c){case'1':add();break;//跳转添加设备界面case'2':delequ();break;//跳转删除界面case'3':change();break;//跳转修改界面case'4':find();break;//跳转查询界面case 27:manner();}}}void add()//设备添加界面{PIMAGE adding=newimage();//定义变量getimage(adding,"image/add.png");//获取图片数据putimage(0,0,adding);//图片显示在屏幕窗体上PIMAGE h=newimage();getimage(h,"image/add.png");setbkmode(TRANSPARENT);char c;while(1){putimage(0,0,adding);setfont(25,0,"宋体");for(int i=0;i<100;i++){if(strlen(Et[i].equiptname)<1) //发现空位置{strcpy(Et[i].equiptname,inputstring(203,55));strcpy(Et[i].equiptnumber,inputstring(203,99));strcpy(Et[i].price,inputstring(203,141));strcpy(Et[i].buytime,inputstring(203,184));strcpy(Et[i].location,inputstring(203,228));strcpy(Et[i].condition,inputstring(203,271));strcpy(Et[i].staff,inputstring(203,323));strcpy(Et[i].number,inputstring(203,366));strcpy(Et[i].usetime,inputstring(203,411));break;}}setfont(30,0,"黑体");//设置字体大小类型outtextxy(65, 446, "录入成功:");//设置位置char c=ege::getch();switch(c){case 27:mannerS();break;}}}void user()//用户界面{PIMAGE usering=newimage();//定义变量getimage(usering,"image/user.png");//获取图片数据putimage(0,0,usering);//图片显示在屏幕窗体上char key=getch();switch(key){case'1':report();break;case'2':findreport();break;case 27:login();}return ;}void report()//上报信息界面{PIMAGE reporting=newimage();//定义变量getimage(reporting,"image/report.jpg");//获取图片数据putimage(0,0,reporting);//图片显示在屏幕窗体上while(1){setfont(25,0,"宋体");for(int i=0;i<100;i++){if(strlen(Rt[i].equiptname)<1) //发现空位置{strcpy(Rt[i].roomnumber,inputstring(130,115));strcpy(Rt[i].equiptname,inputstring(130,168));strcpy(Rt[i].fault,inputstring(130,225));strcpy(Rt[i].number,inputstring(130,279));strcpy(Rt[i].reporter,inputstring(130,329));strcpy(Rt[i].reporttime,inputstring(130,377));break;}}setfont(30,0,"黑体");//设置字体大小类型outtextxy(65, 446, "录入成功:");//设置位置char c=ege::getch();switch(c){case 27:user();break;}}return ;}void findreport()//上报信息显示界面{PIMAGE findreporting=newimage();//定义变量getimage(findreporting,"image/findreport.png");//获取图片数据putimage(0,0,findreporting);//图片显示在屏幕窗体上while(1){for(int i=0;i<100;i++){if(strlen(Rt[i].roomnumber)>0) //发现空位置{outtextxy(73,200+30*i,Rt[i].roomnumber);outtextxy(171,200+30*i,Rt[i].equiptname);outtextxy(279,200+30*i,Rt[i].fault);outtextxy(382,200+30*i,Rt[i].number);outtextxy(484,200+30*i,Rt[i].reporter);outtextxy(585,200+30*i,Rt[i].reporttime);}}char key=getch();switch(key){case 27:user();break ;}}return ;}void delequ()//删除设备界面{cleardevice();//清屏PIMAGE delequing=newimage();//定义变量getimage(delequing,"image/delequ.jpg");//获取图片数据putimage(0,0,delequing);//图片显示在屏幕窗体上char equiptnumber[20];strcpy(equiptnumber,inputstring(170,203));for(int i=0;i<100;i++){if(strcmp(equiptnumber,Et[1].equiptnumber)==0)for(int j=i+1;j<100-i;j++)Et[i]=Et[j];}outtextxy(100,450, "删除成功");//设置位置char c=ege::getch();switch(c){case 27:mannerS();break;}return ;}void find()//查询界面{PIMAGE finding=newimage();//定义变量getimage(finding,"image/find.png");//获取图片数据putimage(0,0,finding);//图片显示在屏幕窗体上char e[20];strcpy(e,inputstring(197,140));while(1){for(int i=0;i<100;i++){if(strcmp(e,Et[i].equiptnumber)==1)/*/////////////////////////////////*/{outtextxy(206,240,Et[i].equiptname);outtextxy(206,276,Et[i].equiptnumber);outtextxy(206,319,Et[i].price);outtextxy(206,354,Et[i].buytime);outtextxy(206,388,Et[i].location);outtextxy(541,237,Et[i].number);outtextxy(541,274,Et[i].price);outtextxy(541,313,Et[i].staff);outtextxy(541,348,Et[i].usetime);}}char c=ege::getch();switch(c){case 27:mannerS();break;}}}void change()//修改界面{PIMAGE changeing=newimage();//定义变量getimage(changeing,"image/change.jpg");//获取图片数据putimage(0,0,changeing);//图片显示在屏幕窗体上PIMAGE h=newimage();getimage(h,"image/change.png");setbkmode(TRANSPARENT);char c;while(1){putimage(0,0,changeing);setfont(25,0,"宋体");for(int i=0;i<100;i++){if(strlen(Et[i].equiptname)<1) //发现空位置{strcpy(Et[i].equiptname,inputstring(203,55));strcpy(Et[i].equiptnumber,inputstring(203,99));strcpy(Et[i].price,inputstring(203,141));strcpy(Et[i].buytime,inputstring(203,184));strcpy(Et[i].location,inputstring(203,228));strcpy(Et[i].condition,inputstring(203,271));strcpy(Et[i].staff,inputstring(203,323));strcpy(Et[i].number,inputstring(203,366));strcpy(Et[i].usetime,inputstring(203,411));break;}}setfont(30,0,"黑体");//设置字体大小类型outtextxy(65, 446, "修改成功!");//设置位置char c=ege::getch();switch(c){case 27:mannerS();break;}}}void about()//关于界面{PIMAGE abouting=newimage();//定义变量getimage(abouting,"image/about.png");//获取图片数据putimage(0,0,abouting);//图片显示在屏幕窗体上getch();login();return ;}void help()//帮助界面{PIMAGE helping=newimage();//定义变量getimage(helping,"image/help.jpg");//获取图片数据putimage(0,0,helping);//图片显示在屏幕窗体上getch();login();return ;}void thank()//退出界面{PIMAGE thanking=newimage();//定义变量getimage(thanking,"image/thank.thank");//获取图片数据putimage(0,0,thanking);//图片显示在屏幕窗体上return ;}int save()//保存文件{FILE *fp; // filename 的文件描述符if((fp=fopen("lab.txt","w"))==NULL){return 0;}for (int i=0;i<30;i++){fprintf(fp,"%20s%20s%20s%20s%20s%20s%20s%20s%20s",Et[i].equiptname,Et[i].equiptnumber,Et[i].price,Et[i].buytime,Et[i].location,Et[i].condition,Et[i].staf f,Et[i].number,Et[i].usetime);fprintf(fp,"%20s%20s%20s%20s%20s%20s",Rt[i].roomnumber,Rt[i].equiptname,Rt[i].fault,Rt[i].reporter,Rt[i].number,Rt[i].reporttime);fprintf(fp,"20s%20s%20s",ur[i].bianhao,ur[i].number,ur[i].username);}fclose(fp);}int load()//读取文件{int i;FILE *fp; // filename 的文件描述符if((fp=fopen("lab.txt","r"))==NULL){return 0;}for (int i=0;i<30;i++){fscanf(fp,"%20s%20s%20s%20s%20s%20s%20s%20s%20s",Et[i].equiptname,Et[i].equiptnumber,Et[i].price,Et[i].buytime,Et[i].location,Et[i].condition,Et[i].staf f,Et[i].number,Et[i].usetime);fscanf(fp,"%20s%20s%20s%20s%20s%20s",Rt[i].roomnumber,Rt[i].equiptname,Rt[i].fault,Rt[i].reporter,Rt[i].number,Rt[i].reporttime);fscanf(fp,"20s%20s%20s",ur[i].bianhao,ur[i].number,ur[i].username);};fclose(fp);}31 / 31。
C#实验室设备管理系统论文+源代码+数据库设计-论文
![C#实验室设备管理系统论文+源代码+数据库设计-论文](https://img.taocdn.com/s3/m/388ad2614a7302768e9939ec.png)
C#实验室设备管理系统论文+源代码+数据库设计-论文C#实验室设备管理系统论文+源代码+数据库设计-论文 C#实验室设备管理系统论文+源代码+数据库设计摘要高校实验室设备是高校从事教学、科研及新产品开发的重要物质条件,也是学校综合实力的体现。
随着实验设备的增多,如何对其进行有效管理成为高校实验室工作人员面临的重要课题。
面对底大的信息量,需要科学、有效的实验室设备信息管理系统来提高实验室管理工作的效率〃做到信息的规范管理、科学统计和快速查询,减少管理方面的工作量。
关键词 :数据库模块管理系统目录第一章绪论.41.1项目提出的意义.41.2 项目背景 .. 4第二章系统设计 ... .52.1开发工具的选取 52.2设计原则 .52.3主要功能的实现 .62.3.1 用户登录模块 62.3.2 系统管理模块 ..62.3.3 设备管理模块 ..62.3.4 用户操作模块 ..62.3.5 数据库设计与数据准备. .7第三章系统实现.. 8 3.1数据库实现.. 83.2界面实现 ..83.2.1总体界面 (8)3.2.2登录界面实现 93.2.3系统管理界面实现 ..10 3.2.3.1添加用户界面 ...10 3.2.3.2删除用户界面 11 3.2.4设备管理界面实现.. .11 3.2.4.1添加设备界面 11 3.2.4.2删除设备界面 1213 3.2.5用户操作界面3.2.5.1修改密码 133.2.5.2返回登录 143.2.6主界面 14第四章结束语 ..16参考文献 17绪论项目提出的意义信息社会的高科技,商品经济化的高效益,使计算机的应用已普及到经济和社会生活的各个领域。
计算机虽然与人类的关系愈来愈密切,还有人由于计算机操作不方便继续用手工劳动。
为了适应现代社会人们高度强烈的时间观念,实验室设备管理系统软件将会为教学办公室带来了极大的方便。
项目背景现今实验室管理的繁索给具有强烈时间观念的办公人员带来了诸多不便,教学办公室缺少一种完善的设备管理软件,为了对学生基本情况管理方便,开发人员完成了全面的调查与分析,同时与目标用户进行了多次深入沟通,并在次基础上着手开发《实验室管理系统》软件。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
if(!equip->next)
{
printf("\n>>>>>>>>>>提示:没有资料可以修改!\n");
return;
}
printf("请输入要修改的设备ID号:");
scanf("%d",&find);
p=equip->next;
}
}
void Add(Node *equip) //添加记录
{
Node *p,*r,*s;
int id; //先用于输入ID,也用于判断是否跳出循环
r=equip;
s=equip->next; //使s为第一个有用的结点
printf("设备号 设备名称 设备种类 报废日期 是否报废 购买时间 价格\n");
while(p)
{
printf("\n%-13d%-11s%-7s%-10d%-13s%-10d%-5d\n",p->data.ID,p->,p->data.kind,p->data.over,p->data.yesno,p->data.time,p->data.price);
printf(">>>>>>>>>>提示:已经完成一条记录的添加。\n");
Node *p0, *p1;
if(equip==NULL)
{
equip=p;
p->next=NULL;
}
if( p->data.ID<equip->data.ID)
{
p->next=equip;
printf("\n请输入设备是否报废:");
scanf("%s",&p->data.yesno);
printf("\n请输入设备购买时间:");
scanf("%d",&p->data.time);
printf("\n请输入设备价格:");
scanf("%d",&p->data.price);
p=p->next;
}
}
void search(Node *equip)/*数据查询函数*/
{
Node *p;
p=equip->next;
int find;
if(!p)
{
printf("\n>>>>>>>>>>提示:没有记录可以显示!\n");
if(equip->next==NULL)
{ printf("无可操作的设备信息!\n");
}
else
{
printf("请输入要删除的设备的ID:");
scanf("%d",&num);
if(equip->data.ID==num)
{
equip=p;
}
p1=equip;
while((p->data.ID > p1->data.ID)&&(p1->next != NULL))
{
p0 = p1;
p1 = p1->next;
}
if(p->data.ID <p1->data.ID)
p->next=q;
p=q; //将该接点挂入链表中
}
fclose(fp); //关闭文件
scanf("%d",&p->data.ID);
printf("请输入新设备名称(原来是 %s ):",p->);
scanf("%s",p->);
printf("请输入新设备设备种类名称(原来是 %s ):",p->data.kind);
}
void main()
{
Node *equip;
FILE *fp;
int flag;
Node *p,*q;
printf("\t\t\t\t实验室设备管理系统\n");
equip=(Node*)malloc(sizeof(Node));
equip->next=NULL;
p=equip;
fp=fopen("D:\\设备管理系统","w+");
q=(Node*)malloc(sizeof(Node));
if(fread(q,sizeof(Node),1,fp)) //将文件的内容放入接点中
{
q->next=NULL;
p=p->next;
}
if(p->data.ID==num)
{pre->next=p->next;
printf("删除成功!!:");}
free(p);
}
}
}
}
void help()
{
printf("在主界面输入1-7的数字\n再按回车键可以进入到相应的功能界面进行操作\n另外:系统保存的文件存放在D:\\设备管理系统,请勿随便删除!!!\n");
int over;
char yesno[50];
int time;
int price;
};
typedef struct node
{
struct shebei data;
struct node *next; //建立一个链表。
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
struct shebei
{
int ID;
char name[100];
char kind[50];
while(r->next!=NULL) //这个循环的作用是使r为最后一个有用的结点
r=r->next; //将指针置于最末尾
while(1)
{
printf(">>>>>>>>>>提示:输入0则返回主菜单!\n");
printf("\n请你输入设备ID号:isp(Node *equip)//输出记录
{
Node *p;
p=equip->next;
if(!p)
{
printf("\n>>>>>>>>>>提示:没有记录可以显示!\n");
return;
}
printf("\t\t\t\t显示结果\n");
scanf("%s",p->data.kind);
printf("请输入新设备报废日期名称(原来是 %d ):",p->data.over);
scanf("%d",&p->data.over);
printf("请输入新设备是否报废(原来是 %s ):",p->data.yesno);
scanf("%s",p->);
printf("\n请输入设备种类:");
scanf("%s",p->data.kind);
printf("\n请输入报废日期:");
scanf("%d",&p->data.over);
{
p->next=p1;
p0->next=p;
}
else
{
p1->next = p;
p->next = NULL;
}
}
}
void Modify(Node *equip)//修改
{
Node *p;
scanf("%d",&id);
if(id==0) {break;}
p=(Node *)malloc(sizeof(Node)); //申请空间
p->data.ID=id;
printf("\n请输入设备名称:");
return;
}
else
{
printf("请输入要查询设备设备的ID:");
scanf("%d",&find);
while(p)
{
if(p->data.ID==find)
{
printf("\t\t\t\t显示结果\n");
printf("设备号 设备名称 设备种类 报废日期 是否报废 购买时间 价格\n");
printf("\n%-13d%-11s%-7s%-10d%-13s%-10d%-5d\n",p->data.ID,p->,p->data.kind,p->data.over,p->data.yesno,p->data.time,p->data.price);