#include #define SIZE sizeof(struct ShiyanEquip) struct ShiyanEquip{ }; //============================================================函数声明 struct ShiyanEquip * NewList(); struct ShiyanEquip * InsertNode( struct ShiyanEquip *head, struct ShiyanEquip *newin); void SearchNode( struct ShiyanEquip *head); void SearchNode_num( struct ShiyanEquip *head, int num); void SearchNode_type( struct ShiyanEquip *head, char type[]); void SearchNode_name( struct ShiyanEquip *head, char name[]); void SearchNode_price( struct ShiyanEquip *head, double price); void SearchNode_btime( struct ShiyanEquip *head, int btime); void SearchNode_otime( struct ShiyanEquip *head, int otime); void SearchNode_able( struct ShiyanEquip *head, int able); struct ShiyanEquip * Delete_num( struct ShiyanEquip *head, int num); void ChangeNode(struct ShiyanEquip *head,int num); void Dealwithpass( struct ShiyanEquip * head , int nowtime); struct ShiyanEquip * manage(); void search(struct ShiyanEquip * head); static count=0; 1 int num; char type[10],name[20]; double price; int btime; int otime; int able; struct ShiyanEquip * next; int main(void) { } //====================================================管理系统 struct ShiyanEquip * manage() { struct ShiyanEquip * head=NULL; char chose; do { printf(\"********Wlecome to use my program ~********\\n\\n\"); printf(\"**********Here is the Menu **********\\n\"); printf(\"*No.1:管理系统 *\\n\"); printf(\"*No.2:查询系统 *\\n\"); printf(\"*No.#:退出系统 *\\n\"); printf(\"*******************************************\\n\"); scanf(\"%s\ switch(chose) { case '1': } head=manage(); break; search(head); break; system(\"cls\"); printf(\"********Thankyou for using my program ~********\\n\\n\"); exit(0); case '2': case '#': }while (1); return 0; char chose2; int num,nowtime; char type[10],name[20]; double price; int btime; 2 int otime; int able; struct ShiyanEquip * pcurr,* head; system(\"cls\"); do{ system(\"cls\"); printf(\"********** 管理系统 **********\\n\"); printf(\"**No.1:建立新实验器材管理清单 **\\n\"); printf(\"**No.2:插入新的实验器材 **\\n\"); printf(\"**No.3:删除目标器材信息 **\\n\"); printf(\"**No.4:修改目标器材信息 **\\n\"); printf(\"**No.5:遗损处理 **\\n\"); printf(\"**No.#:返回上级菜单 **\\n\"); printf(\"********************************\\n\"); scanf(\"%s\ pcurr->num=num; strcpy(pcurr->type,type); strcpy(pcurr->name,name); pcurr->price=price; pcurr->btime=btime; pcurr->otime=otime; pcurr->able=able; head=InsertNode(head,pcurr); break; switch(chose2) { case '1': head=NewList(); break; case '2': pcurr=(struct ShiyanEquip *)malloc(SIZE); printf(\"=输入实验器材的编号,类型,名称,价格,购入时间,报废时间,是否可用(0:报 废;1:可用)=\\n\"); scanf(\"%d%s%s%lf%d%d%d\ case '3': printf(\"=请输入要删除的实验器材的编号=:\"); scanf(\"%d\ head=Delete_num(head,num); break; case '4': 3 } } printf(\"=请输入要修改的实验器材的编号=:\"); scanf(\"%d\ChangeNode(head,num); break; printf(\"=请输入现在的日期=\"); scanf(\"%d\Dealwithpass(head,nowtime); break; system(\"cls\"); return head; case '5': case '#': }while ( 1); return head; struct ShiyanEquip * NewList()//=====================================新建链表 { head=tail=NULL; printf(\"录入实验器材的信息.....\\n\"); int num; char type[10],name[20]; double price; int btime; int otime; int able; struct ShiyanEquip * p,* head,* tail; printf(\"=输入实验器材的编号,类型,名称,价格,购入时间,报废时间,是否可用(0:报废;1:可用)=\\n\"); scanf(\"%d%s%s%lf%d%d%d\ while ( num != 0) { p=(struct ShiyanEquip *)malloc(SIZE); p->num=num; strcpy(p->type,type); strcpy(p->name,name); p->price=price; p->btime=btime; p->otime=otime; p->able=able; 4 } p->next = NULL; if (head == NULL) head = p; else tail->next = p; tail = p; printf(\"=输入实验器材的编号,类型,名称,价格,购入时间,报废时间,是否可用(0:报废;1:scanf(\"%d%s%s%lf%d%d%d\ } return head; 可用)=\\n\"); struct ShiyanEquip * InsertNode (struct ShiyanEquip * head,struct ShiyanEquip *newin) //插入节点 { } struct ShiyanEquip * Delete_num( struct ShiyanEquip * head,int num)//======删除节点 { struct ShiyanEquip * pt1,* pt2; pt1=head; pt2=newin; if (head == NULL) { head = pt2; head ->next = NULL; count++; { } pt2 ->next = pt1 ->next; pt1 ->next = pt2; count++; }else return head; struct ShiyanEquip * pt1,* pt2; 5 } void ChangeNode(struct ShiyanEquip *head,int num)//===================更改节点 { if ( head == NULL ) else { } return head; if ( head -> num == num) { { } pt1 = head; pt2 = head -> next; if (pt2 != NULL) { } if (pt2 -> num == num) { { } pt1 = pt2; pt2 = pt1 -> next; pt1 -> next = pt2 -> next; free(pt2); count--; pt2 = head; head = head -> next; free(pt2); count--; return head; return NULL; }else }else char type[10],name[20]; double price; int btime; int otime; int able; 6 int flag=0,chose4; struct ShiyanEquip *pt; if (head == NULL) { printf(\"=抱歉,没有任何信息!=\\n\"); } for( pt = head; pt ; pt = pt -> next) if(pt->num == num) { printf(\"====选择要修改的信息====\\n\"); printf(\"=1.编号 =\\n\"); printf(\"=2.类型 =\\n\"); printf(\"=3.名称 =\\n\"); printf(\"=4.价格 =\\n\"); printf(\"=5.购入时间 =\\n\"); printf(\"=6.报废时间 =\\n\"); switch(chose4) { case 1:printf(\"=请输入新的信息 return; printf(\"=7.是否可用 =\\n\"); =\");scanf(\"%d\ case 2:printf(\"=请输入新的信息=\");scanf(\"%s\ case 3:printf(\"=请输入新的信息=\");scanf(\"%s\ case 4:printf(\"=请输入新的信息=\");scanf(\"%lf\ case 5:printf(\"=请输入新的信息=\");scanf(\"%d\ case 6:printf(\"=请输入新的信息 =\");scanf(\"%d\ case 7:printf(\"=请输入新的信息=\");scanf(\"%d\ } //===========================================================查询系统 void search(struct ShiyanEquip * head) { } } int num; 7 char type[10],name[20]; double price; int btime; int otime; int able; char chose3; system(\"cls\"); do{ system(\"cls\"); printf(\"********** 查询系统 **********\\n\"); printf(\"**No.1:按编号查找 **\\n\"); printf(\"**No.2:查找统一价格 **\\n\"); printf(\"**No.3:查找同一类型 **\\n\"); printf(\"**No.4:查找同一名称 **\\n\"); printf(\"**No.5:查找按购入日期 **\\n\"); printf(\"**No.6:查找按报废日期 **\\n\"); printf(\"**No.7:查找按是否可用 **\\n\"); printf(\"**No.8:显示全部器材信息 **\\n\"); printf(\"**No.#:返回上一级菜单 **\\n\"); printf(\"********************************\\n\"); scanf(\"%s\ switch(chose3) { case '1': printf(\"=请输入要查找的编号=\"); scanf(\"%d\SearchNode_num(head,num); break; case '2': printf(\"=请输入想要查看的价格=\"); scanf(\"%lf\ SearchNode_price(head,price); break; case '3': printf(\"=请输入想要查找的类型=\"); scanf(\"%s\ SearchNode_type(head,type); break; case '4': printf(\"=请输入想要查看的名称=\"); scanf(\"%s\ SearchNode_name(head,name); 8 } break; case '5': printf(\"=请输入想要查看的购入时间=\"); scanf(\"%d\ SearchNode_btime(head,btime); break; printf(\"=请输入想要查看的报废时间=\"); scanf(\"%d\ SearchNode_otime(head,otime); break; case '6': case '7': printf(\"=请输入要查看是否可用的器材(0:报废;1:可用)=\"); } scanf(\"%d\SearchNode_able(head,able); break; SearchNode(head); break; system(\"cls\"); return; case '8': case '#': }while ( 1); void SearchNode_num( struct ShiyanEquip *head, int num)//按编号查找 { FILE *fp; if (( fp = fopen(\"result.txt\ { printf(\"===文件打开错误!===\\n\"); } int flag=0; struct ShiyanEquip *pt; if (head == NULL) { printf(\"=抱歉,没有任何信息!=\\n\"); for( int i=5;i>0;i--) { 9 exit(0); } printf(\"%d秒后请重新操作\\n\ Sleep(1000); } return; for( pt = head; pt ; pt = pt -> next) { if(pt->num == num) { } flag=1; printf(\"=============================\\n\"); printf(\"=编号%d \\n\ printf(\"=类型%s \\n\ printf(\"=名称%s \\n\ printf(\"=价格%.1lf \\n\ printf(\"=购入时间%d \\n\ printf(\"=报废时间%d \\n\ printf(\"=是否可用%d \\n\ printf(\"=============================\\n\"); fprintf(fp,\"=============================\\n\"); fprintf(fp,\"=编号%d \\n\ fprintf(fp,\"=类型%s \\n\ fprintf(fp,\"=名称%s \\n\ fprintf(fp,\"=价格%.1lf \\n\ fprintf(fp,\"=购入时间%d \\n\ fprintf(fp,\"=报废时间%d \\n\ fprintf(fp,\"=是否可用%d \\n\ fprintf(fp,\"=============================\\n\"); for( int i=10;i>0;i--) { Sleep(1000); } printf(\"=可以在文件result.txt中查看更多=\\n\"); if ( flag == 0) printf(\"=抱歉没有找到您所要查找的器材~=\\n\"); for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } 10 } } if ( fclose(fp) ) { } printf(\"===文件关闭错误===\\n\"); exit(0); void SearchNode_type( struct ShiyanEquip *head, char type[])//按类型查找 { FILE *fp; if (( fp = fopen(\"result.txt\ { printf(\"===文件打开错误!===\\n\"); } int countS=0; struct ShiyanEquip *pt; if (head == NULL) { printf(\"=抱歉,没有任何信息!=\\n\"); } for( pt = head; pt ; pt = pt -> next) if (strcmp(pt->type,type) == 0) { countS++; printf(\"=============================\\n\"); printf(\"=编号%d \\n\ printf(\"=类型%s \\n\ printf(\"=名称%s \\n\ printf(\"=价格%.1lf \\n\ printf(\"=购入时间%d \\n\ printf(\"=报废时间%d \\n\ printf(\"=是否可用%d \\n\ printf(\"=============================\\n\"); 11 exit(0); for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } return; } 12 } fprintf(fp,\"=============================\\n\"); fprintf(fp,\"=编号%d \\n\ fprintf(fp,\"=类型%s \\n\ fprintf(fp,\"=名称%s \\n\ fprintf(fp,\"=价格%.1lf \\n\ fprintf(fp,\"=购入时间%d \\n\ fprintf(fp,\"=报废时间%d \\n\ fprintf(fp,\"=是否可用%d \\n\ fprintf(fp,\"=============================\\n\"); for( int i=10;i>0;i--) { Sleep(1000); } if ( countS == 0) { printf(\"=抱歉没有找到您所要查找的器材~=\\n\"); } else { printf(\"=共查找到%d条信息=\\n\ } printf(\"=可以在文件result.txt中查看更多=\\n\"); fprintf(fp,\"=共查找到%d条信息=\\n\for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } if ( fclose(fp) ) { printf(\"===文件关闭错误===\\n\"); } exit(0); void SearchNode_name( struct ShiyanEquip *head, char name[])//按名称查找 { FILE *fp; if (( fp = fopen(\"result.txt\ { } int countS=0; struct ShiyanEquip *pt; if (head == NULL) { printf(\"=抱歉,没有任何信息!=\\n\"); } for( pt = head; pt ; pt = pt -> next) if (strcmp(pt -> name,name) == 0) { countS++; printf(\"=============================\\n\"); printf(\"=编号%d \\n\ printf(\"=类型%s \\n\ printf(\"=名称%s \\n\ printf(\"=价格%.1lf \\n\ printf(\"=购入时间%d \\n\ printf(\"=报废时间%d \\n\ printf(\"=是否可用%d \\n\ printf(\"=============================\\n\"); fprintf(fp,\"=============================\\n\"); fprintf(fp,\"=编号%d \\n\ fprintf(fp,\"=类型%s \\n\ fprintf(fp,\"=名称%s \\n\ fprintf(fp,\"=价格%.1lf \\n\ fprintf(fp,\"=购入时间%d \\n\ 13 printf(\"===文件打开错误!===\\n\"); exit(0); for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } return; } } fprintf(fp,\"=报废时间%d \\n\ fprintf(fp,\"=是否可用%d \\n\ fprintf(fp,\"=============================\\n\"); for( int i=10;i>0;i--) { Sleep(1000); } if ( countS == 0) { printf(\"=抱歉没有找到您所要查找的器材~=\\n\"); } else { printf(\"=共查找到%d条信息=\\n\ } printf(\"=可以在文件result.txt中查看更多=\\n\"); fprintf(fp,\"=共查找到%d条信息=\\n\for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } if ( fclose(fp) ) { printf(\"===文件关闭错误===\\n\"); } exit(0); void SearchNode_price( struct ShiyanEquip *head, double price)//按价格查找 { FILE *fp; if (( fp = fopen(\"result.txt\ { printf(\"===文件打开错误!===\\n\"); 14 } exit(0); int countS=0; struct ShiyanEquip *pt; if (head == NULL) { printf(\"=抱歉,没有任何信息!=\\n\"); } for( pt = head; pt ; pt = pt -> next) if(pt -> price == price) { } 15 for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } return; countS++; printf(\"=============================\\n\"); printf(\"=编号%d \\n\ printf(\"=类型%s \\n\ printf(\"=名称%s \\n\ printf(\"=价格%.1lf \\n\ printf(\"=购入时间%d \\n\ printf(\"=报废时间%d \\n\ printf(\"=是否可用%d \\n\ printf(\"=============================\\n\"); fprintf(fp,\"=============================\\n\"); fprintf(fp,\"=编号%d \\n\ fprintf(fp,\"=类型%s \\n\ fprintf(fp,\"=名称%s \\n\ fprintf(fp,\"=价格%.1lf \\n\ fprintf(fp,\"=购入时间%d \\n\ fprintf(fp,\"=报废时间%d \\n\ fprintf(fp,\"=是否可用%d \\n\ fprintf(fp,\"=============================\\n\"); for( int i=10;i>0;i--) { Sleep(1000); } } if ( countS == 0) { printf(\"=抱歉没有找到您所要查找的器材~=\\n\"); } else { } printf(\"=共查找到%d条信息=\\n\ printf(\"=可以在文件result.txt中查看更多=\\n\"); fprintf(fp,\"=共查找到%d条信息=\\n\for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } if ( fclose(fp) ) { printf(\"===文件关闭错误===\\n\"); } exit(0); void SearchNode_btime( struct ShiyanEquip *head, int btime)//按购入时间查找 { FILE *fp; if (( fp = fopen(\"result.txt\ { } int countS=0; struct ShiyanEquip *pt; if (head == NULL) { printf(\"=抱歉,没有任何信息!=\\n\"); for( int i=5;i>0;i--) 16 printf(\"===文件打开错误!===\\n\"); exit(0); } { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } return; for( pt = head; pt ; pt = pt -> next) if(pt -> btime == btime) { } { printf(\"=抱歉没有找到您所要查找的器材~=\\n\"); for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } 17 countS++; printf(\"=============================\\n\"); printf(\"=编号%d \\n\ printf(\"=类型%s \\n\ printf(\"=名称%s \\n\ printf(\"=价格%.1lf \\n\ printf(\"=购入时间%d \\n\ printf(\"=报废时间%d \\n\ printf(\"=是否可用%d \\n\ printf(\"=============================\\n\"); fprintf(fp,\"=============================\\n\"); fprintf(fp,\"=编号%d \\n\ fprintf(fp,\"=类型%s \\n\ fprintf(fp,\"=名称%s \\n\ fprintf(fp,\"=价格%.1lf \\n\ fprintf(fp,\"=购入时间%d \\n\ fprintf(fp,\"=报废时间%d \\n\ fprintf(fp,\"=是否可用%d \\n\ fprintf(fp,\"=============================\\n\"); for( int i=10;i>0;i--) { Sleep(1000); } if ( countS == 0) } } else { } printf(\"=共查找到%d条信息=\\n\ printf(\"=可以在文件result.txt中查看更多=\\n\"); fprintf(fp,\"=共查找到%d条信息=\\n\for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } if ( fclose(fp) ) { printf(\"===文件关闭错误===\\n\"); } exit(0); void SearchNode_able( struct ShiyanEquip *head, int able)//按是否可用查找 { if (( fp = fopen(\"result.txt\ { printf(\"===文件打开错误!===\\n\"); } int countS=0; struct ShiyanEquip *pt; if (head == NULL) { printf(\"=抱歉,没有任何信息!=\\n\"); } for( pt = head; pt ; pt = pt -> next) if(pt -> able == able) { 18 FILE *fp; exit(0); for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } return; } countS++; printf(\"=============================\\n\"); printf(\"=编号%d \\n\ printf(\"=类型%s \\n\ printf(\"=名称%s \\n\ printf(\"=价格%.1lf \\n\ printf(\"=购入时间%d \\n\ printf(\"=报废时间%d \\n\ printf(\"=是否可用%d \\n\ printf(\"=============================\\n\"); fprintf(fp,\"=============================\\n\"); fprintf(fp,\"=编号%d \\n\ fprintf(fp,\"=类型%s \\n\ fprintf(fp,\"=名称%s \\n\ fprintf(fp,\"=价格%.1lf \\n\ fprintf(fp,\"=购入时间%d \\n\ fprintf(fp,\"=报废时间%d \\n\ fprintf(fp,\"=是否可用%d \\n\ fprintf(fp,\"=============================\\n\"); for( int i=10;i>0;i--) { Sleep(1000); } if ( countS == 0) { printf(\"=抱歉没有找到您所要查找的器材~=\\n\"); } else { printf(\"=共查找到%d条信息=\\n\ fprintf(fp,\"=共查找到%d条信息=\\n\for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); 19 for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } } } } if ( fclose(fp) ) { printf(\"===文件关闭错误===\\n\"); } exit(0); void SearchNode_otime( struct ShiyanEquip *head, int otime)//按报废时间查找 { FILE *fp; if (( fp = fopen(\"result.txt\ { printf(\"===文件打开错误!===\\n\"); } int countS=0; struct ShiyanEquip *pt; if (head == NULL) { printf(\"=抱歉,没有任何信息!=\\n\"); } for( pt = head; pt ; pt = pt -> next) if(pt -> otime == otime) { countS++; printf(\"=============================\\n\"); printf(\"=编号%d \\n\ printf(\"=类型%s \\n\ printf(\"=名称%s \\n\ printf(\"=价格%.1lf \\n\ printf(\"=购入时间%d \\n\ printf(\"=报废时间%d \\n\ printf(\"=是否可用%d \\n\ printf(\"=============================\\n\"); 20 exit(0); for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } return; } 21 } fprintf(fp,\"=============================\\n\"); fprintf(fp,\"=编号%d \\n\ fprintf(fp,\"=类型%s \\n\ fprintf(fp,\"=名称%s \\n\ fprintf(fp,\"=价格%.1lf \\n\ fprintf(fp,\"=购入时间%d \\n\ fprintf(fp,\"=报废时间%d \\n\ fprintf(fp,\"=是否可用%d \\n\ fprintf(fp,\"=============================\\n\"); for( int i=10;i>0;i--) { Sleep(1000); } if ( countS == 0) { printf(\"=抱歉没有找到您所要查找的器材~=\\n\"); for( int i=5;i>0;i--) } else { printf(\"=共查找到%d条信息=\\n\ } printf(\"=可以在文件result.txt中查看更多=\\n\"); fprintf(fp,\"=共查找到%d条信息=\\n\for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } if ( fclose(fp) ) { printf(\"===文件关闭错误===\\n\"); } exit(0); void SearchNode( struct ShiyanEquip *head)//====================查看所有设备信息 { FILE *fp; if (( fp = fopen(\"all_result.txt\ { printf(\"===文件打开错误!===\\n\"); } int countS=0; struct ShiyanEquip *pt; if (head == NULL) { printf(\"=抱歉,没有任何信息!=\\n\"); } for( pt = head; pt ; pt = pt -> next) { printf(\"=============================\\n\"); printf(\"=编号%d \\n\ printf(\"=类型%s \\n\ printf(\"=名称%s \\n\ printf(\"=价格%.1lf \\n\ printf(\"=购入时间%d \\n\ printf(\"=报废时间%d \\n\ printf(\"=是否可用%d \\n\ printf(\"=============================\\n\"); fprintf(fp,\"=============================\\n\"); fprintf(fp,\"=编号%d \\n\ fprintf(fp,\"=类型%s \\n\ fprintf(fp,\"=名称%s \\n\ fprintf(fp,\"=价格%.1lf \\n\ fprintf(fp,\"=购入时间%d \\n\ fprintf(fp,\"=报废时间%d \\n\ fprintf(fp,\"=是否可用%d \\n\ fprintf(fp,\"=============================\\n\"); 22 exit(0); for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } return; } } for( int i=10;i>0;i--) { Sleep(1000); } if ( countS == 0) printf(\"=抱歉没有找到您所要查找的器材~=\\n\"); for( int i=5;i>0;i--) } else { printf(\"=共查找到%d条信息=\\n\ } printf(\"=可以在文件all_result.txt中查看更多=\\n\"); fprintf(fp,\"=共查找到%d条信息=\\n\for( int i=5;i>0;i--) { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } { printf(\"%d秒后请重新操作\\n\ Sleep(1000); } { if ( fclose(fp) ) { printf(\"===文件关闭错误===\\n\"); } exit(0); //==================================================================== void Dealwithpass( struct ShiyanEquip * head , int nowtime) { struct ShiyanEquip *pt; } for ( pt = head; pt ; pt = pt -> next) if ((pt->otime) < nowtime) {Delete_num(head,pt -> num);}; 23
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- vipyiyao.com 版权所有 湘ICP备2023022495号-8
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务