您好,登錄后才能下訂單哦!
本文小編為大家詳細(xì)介紹“C語言如何實(shí)現(xiàn)實(shí)驗(yàn)設(shè)備管理系統(tǒng)”,內(nèi)容詳細(xì),步驟清晰,細(xì)節(jié)處理妥當(dāng),希望這篇“C語言如何實(shí)現(xiàn)實(shí)驗(yàn)設(shè)備管理系統(tǒng)”文章能幫助大家解決疑惑,下面跟著小編的思路慢慢深入,一起來學(xué)習(xí)新知識吧。
實(shí)驗(yàn)設(shè)備信息包括:設(shè)備編號,設(shè)備種類(如:微機(jī)、打印機(jī)、掃描儀等等),設(shè) 備名稱,設(shè)備價格,設(shè)備購入日期,是否報廢,報廢日期等。
功能1:打開一個設(shè)備信息文件,并讀取
功能2:添加新的設(shè)備內(nèi)容并保存
功能3: 統(tǒng)計(jì)設(shè)備數(shù)量
功能4:查找符合條件的設(shè)備及其數(shù)量并將其顯示出來
功能5:對設(shè)備信息按條件進(jìn)行分類排序
功能6:修改設(shè)備信息
功能7:刪除某條設(shè)備記錄
功能8:顯示內(nèi)容
#include "stdio.h" #include "stdlib.h" #define COUNT 30 void start(); //函數(shù)聲明 void input(); void change(); void sort(); void dele(); void output(); void search(); struct deviceInfor{ char devno[30]; int devsort; //1 代表微機(jī) 2代表打印機(jī) 3代表掃描機(jī) char devname[30]; int devprice; char devbuydate[30]; int devstate; char devdonedate[30]; }dev[COUNT]; int count=0; main() //主函數(shù) { while(1) start(); } void start() //啟動菜單 { int chi; printf(" 實(shí)驗(yàn)設(shè)備管理系統(tǒng)\n"); printf(" |-----------------------------------------------|\n"); printf(" | ******************************************** |\n"); printf(" | 1.設(shè)備信息的錄入: |\n"); printf(" | 2.設(shè)備信息的修改: |\n"); printf(" | 3.設(shè)備信息的分類統(tǒng)計(jì): |\n"); printf(" | 4.刪除某個設(shè)備: |\n"); printf(" | 5.查找某個設(shè)備: |\n"); printf(" | 6.退出系統(tǒng): |\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("你已經(jīng)退出設(shè)備管理系統(tǒng)!\n"); exit(0);} else { printf(" You Enter The Choice Is Not valid ! \n"); } } void input() //數(shù)據(jù)錄入 { char flag[20]; do{ printf("請輸入你的設(shè)備信息:\n"); printf("設(shè)備編號:"); scanf("%s",dev[count].devno); printf("設(shè)備種類(1 代表微機(jī) 2代表打印機(jī) 3代表掃描機(jī)):"); scanf("%d",&dev[count].devsort); printf("設(shè)備名字:"); scanf("%s",dev[count].devname); printf("設(shè)備價格:"); scanf("%d",&dev[count].devprice); printf("設(shè)備購買日期:"); scanf("%s",dev[count].devbuydate); printf("設(shè)備狀態(tài)(1未報廢 0報廢):"); scanf("%d",&dev[count].devstate); printf("設(shè)備報廢日期:"); scanf("%s",dev[count].devdonedate); count++; printf("是否繼續(xù)輸入數(shù)據(jù) y是 n否 : "); scanf("%s",flag); }while(strcmp(flag,"y")==0||strcmp(flag,"Y")==0); output(); } void change() //數(shù)據(jù)修改 { 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() //數(shù)據(jù)分類顯示 { int i,chi,sum=0,wei=0,da=0,sao=0; printf("輸入你想要統(tǒng)計(jì)的信息: 1(報廢的機(jī)器總數(shù)) 2(機(jī)器的總類數(shù)目)"); scanf("%d",&chi); if(chi==1) { for(i=0;i<count;i++) { if(dev[i].devstate==0) sum++; } printf("報廢的機(jī)器數(shù)目為 %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("微機(jī)數(shù)目為 %d 打印機(jī)數(shù)目為 %d 掃描機(jī)數(shù)目為 %d",wei,da,sao); }else { printf("你輸入的選項(xiàng)不符合要求!\n");} } void dele() //數(shù)據(jù)刪除 { 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() //數(shù)據(jù)輸出 { 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() //數(shù)據(jù)查找 { 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語言如何實(shí)現(xiàn)實(shí)驗(yàn)設(shè)備管理系統(tǒng)”文章已經(jīng)介紹完畢,想要掌握這篇文章的知識點(diǎn)還需要大家自己動手實(shí)踐使用過才能領(lǐng)會,如果想了解更多相關(guān)內(nèi)容的文章,歡迎關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。