本文小编为大家详细介绍“C语言如何实现实验设备管理系统”,内容详细,步骤清晰,细节处理妥当,希望这篇“C语言如何实现实验设备管理系统”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。
一、任务概述
实验设备信息包括:设备编号,设备种类(如:微机、打印机、扫描仪等等),设 备名称,设备价格,设备购入日期,是否报废,报废日期等。
二、模块划分
功能1:打开一个设备信息文件,并读取
功能2:添加新的设备内容并保存
功能3: 统计设备数量
功能4:查找符合条件的设备及其数量并将其显示出来
功能5:对设备信息按条件进行分类排序
功能6:修改设备信息
功能7:删除某条设备记录
功能8:显示内容
三、功能展示
四、思维导图
五、程序源码
#include "stdio.h"#include "stdlib.h"#define COUNT 30void start(); //函数声明void input();void change();void sort();void dele();void output();void search();struct deviceInfor{ char devno[30]; int devsort; //1 代表微机 2代表打印机 3代表扫描机 char devname[30]; int devprice; char devbuydate[30]; int devstate; char devdonedate[30];}dev[COUNT];int count=0; main() //主函数{ while(1) start(); }void start() //启动菜单{ int chi; printf(" 实验设备管理系统\n"); printf(" |-----------------------------------------------|\n"); printf(" | ******************************************** |\n"); printf(" | 1.设备信息的录入: |\n"); printf(" | 2.设备信息的修改: |\n"); printf(" | 3.设备信息的分类统计: |\n"); printf(" | 4.删除某个设备: |\n"); printf(" | 5.查找某个设备: |\n"); printf(" | 6.退出系统: |\n"); printf(" | ******************************************** |\n"); printf(" |-----------------------------------------------|\n"); printf(" 输入你的选择: "); scanf("%d",&chi); //printf("\n"); if(chi==1) input(); else if(chi==2) change(); else if(chi==3) sort(); else if(chi==4) dele(); else if(chi==5) search(); else if(chi==6) { printf("你已经退出设备管理系统!\n"); exit(0);} else { printf(" You Enter The Choice Is Not valid ! \n"); }}void input() //数据录入{ char flag[20]; do{ printf("请输入你的设备信息:\n"); printf("设备编号:"); scanf("%s",dev[count].devno); printf("设备种类(1 代表微机 2代表打印机 3代表扫描机):"); scanf("%d",&dev[count].devsort); printf("设备名字:"); scanf("%s",dev[count].devname); printf("设备价格:"); scanf("%d",&dev[count].devprice); printf("设备购买日期:"); scanf("%s",dev[count].devbuydate); printf("设备状态(1未报废 0报废):"); scanf("%d",&dev[count].devstate); printf("设备报废日期:"); scanf("%s",dev[count].devdonedate); count++; printf("是否继续输入数据 y是 n否 : "); scanf("%s",flag); }while(strcmp(flag,"y")==0||strcmp(flag,"Y")==0); output();}void change() //数据修改{ char ch[20],a[20]; int i; printf("\nyou sure want change devInfor y/n): "); scanf("%s",ch); if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0) { printf("\nenter you want change devName:"); scanf("%s",a); for(i=0;i<count;i++) { if(strcmp(dev[i].devname,a)==0) { printf("\nyou sure want change dev name(y/n): "); scanf("%s",ch); if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0) { printf("\nname:"); scanf("%s",dev[i].devname);} printf("\nyou sure want change dev no(y/n): "); scanf("%s",ch); if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0) { printf("\nno"); scanf("%s",dev[i].devno);} printf("\nyou sure want change dev sort(y/n): "); scanf("%s",ch); if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0) { printf("\nsort"); scanf("%d",&dev[i].devsort);} printf("\nyou sure want dev price(y/n): "); scanf("%s",ch);if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0) { printf("\nprice"); scanf("%d",&dev[i].devprice);} printf("\nyou sure want dev done date(y/n): "); scanf("%s",ch);if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0) { printf("\ndone date"); scanf("%s",dev[i].devdonedate);} }} }output();}void sort() //数据分类显示{ int i,chi,sum=0,wei=0,da=0,sao=0; printf("输入你想要统计的信息: 1(报废的机器总数) 2(机器的总类数目)"); scanf("%d",&chi); if(chi==1) { for(i=0;i<count;i++) { if(dev[i].devstate==0) sum++; } printf("报废的机器数目为 %d \n",sum); } else if(chi==2){ for(i=0;i<count;i++) { if(dev[i].devsort==1) wei++; else if(dev[i].devsort==2) da++; else if(dev[i].devsort==3) sao++; } printf("微机数目为 %d 打印机数目为 %d 扫描机数目为 %d",wei,da,sao); }else { printf("你输入的选项不符合要求!\n");}}void dele() //数据删除{int i,j;char c[20]; printf("\nenter you want delete name :\n"); printf("name:"); scanf("%s",c); for(i=0;i<count;i++) if(strcmp(c,dev[i].devname)==0) break; for(j=i;j<count-1;j++) dev[j]=dev[j+1]; printf("\t\t\tyou had delete %s\n",c); count--; output();}void output() //数据输出{ int i; for(i=0;i<count;i++) { printf("%s %d %s %d %s %d %s\n",dev[i].devno,dev[i].devsort,dev[i].devname,dev[i].devprice,dev[i].devbuydate,dev[i].devstate,dev[i].devdonedate); }}void search() //数据查找{int i;char a[20],ch[10]; printf("\nenter you want look name:"); scanf("%s",a); for(i=0;i<count;i++) if(strcmp(dev[i].devname,a)==0) printf("%s %d %s %d %s %d %s\n",dev[i].devno,dev[i].devsort,dev[i].devname,dev[i].devprice,dev[i].devbuydate,dev[i].devstate,dev[i].devdonedate);}
读到这里,这篇“C语言如何实现实验设备管理系统”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注编程网行业资讯频道。