|
|
@ -0,0 +1,467 @@
|
|
|
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
|
|
|
#include<string.h>
|
|
|
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
|
|
|
#include<conio.h>
|
|
|
|
|
|
|
|
#define N 1000 /*存储1000个设备的设备信息*/
|
|
|
|
|
|
|
|
int flag; /*标记是否登录*/
|
|
|
|
|
|
|
|
struct date /*购买日期*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int year;
|
|
|
|
|
|
|
|
int month;
|
|
|
|
|
|
|
|
int day;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct machine
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char num[20];/*编号*/
|
|
|
|
|
|
|
|
char name[25];/*名称*/
|
|
|
|
|
|
|
|
char kind[10];/*种类*/
|
|
|
|
|
|
|
|
char price[10];/*价格*/
|
|
|
|
|
|
|
|
char way[10];/*遗损处理办法*/
|
|
|
|
|
|
|
|
char lost[10];/*损耗费用*/
|
|
|
|
|
|
|
|
struct date birthday;/*购买年月*/
|
|
|
|
|
|
|
|
char yesno[10];/*是否报废Y或者N*/
|
|
|
|
|
|
|
|
struct date time;/*报废时间*/
|
|
|
|
|
|
|
|
}stu[N];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void printf_one(int k) /*输出一个设备的信息*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("color 4e");
|
|
|
|
|
|
|
|
printf("编号:%s\n",stu[k].num);
|
|
|
|
|
|
|
|
printf("名称:%s\n",stu[k].name);
|
|
|
|
|
|
|
|
printf("种类:%s\n",stu[k].kind);
|
|
|
|
|
|
|
|
printf("价格;%s\n",stu[k].price);
|
|
|
|
|
|
|
|
printf("购买年月:%d/%d/%d\n",stu[k].birthday.year,stu[k].birthday.month,stu[k].birthday.day);
|
|
|
|
|
|
|
|
printf("是否报废:%s\n",stu[k].yesno);
|
|
|
|
|
|
|
|
printf("报废时间:%d/%d/%d\n",stu[k].time.year,stu[k].time.month,stu[k].time.day);
|
|
|
|
|
|
|
|
printf("遗损处理办法;%s\n",stu[k].way);
|
|
|
|
|
|
|
|
printf("损耗费用:%s\n",stu[k].lost);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void printf_n(int n) /*浏览时输出所有设备的信息*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("color 2e");
|
|
|
|
|
|
|
|
int j,i=1;
|
|
|
|
|
|
|
|
for(j=0;j<n;j++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("第%d个设备:\n",i++);
|
|
|
|
|
|
|
|
printf_one(j);
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int load() /*打开文件,读取里面的数据*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if((fp=fopen("D:\\file.txt","rb"))==NULL) /*读入空文件,rb表示打开一个二进制文件,只允许读数据*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n文件不存在!请输入:\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0;!feof(fp);i++) /*处理到文件结尾*/
|
|
|
|
|
|
|
|
fread(&stu[i],sizeof(struct machine),1,fp); /*fread(buffer,size,cout,fp)将磁盘文件中的一批数据作为一个整体一次性读取出来,
|
|
|
|
|
|
|
|
buffer指定数据块位置,sizeof数据块字节数,count读取次数,fp指向源磁盘文件*/
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
return(i-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void input(int k) /*输入设备信息*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
printf("编号:"); gets(stu[k].num);
|
|
|
|
|
|
|
|
printf("名称:"); gets(stu[k].name);
|
|
|
|
|
|
|
|
printf("种类;"); gets(stu[k].kind);
|
|
|
|
|
|
|
|
printf("价格:"); scanf("%s",stu[k].price);
|
|
|
|
|
|
|
|
printf("购买日期:"); scanf("%d/%d/%d",&stu[k].birthday.year,&stu[k].birthday.month,&stu[k].birthday.day);
|
|
|
|
|
|
|
|
printf("是否报废:"); scanf("%s",&stu[k].yesno); getchar();
|
|
|
|
|
|
|
|
printf("报废时间:"); scanf("%d/%d/%d",&stu[k].time.year,&stu[k].time.month,&stu[k].time.day);
|
|
|
|
|
|
|
|
printf("遗损处理办法;"); scanf("%s",&stu[k].way); getchar();
|
|
|
|
|
|
|
|
printf("损耗费用;"); scanf("%s",&stu[k].lost); getchar();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void save(int n) /*保存设备信息*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
void exit();
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if((fp=fopen("D:\\file.txt","wb"))==NULL) /*只打开或建立一个二进制文件,只允许写数据*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\nCan not open file!\n");
|
|
|
|
|
|
|
|
exit();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
|
|
|
if(stu[i].name[0]!='\0')
|
|
|
|
|
|
|
|
if(fwrite(&stu[i],sizeof(struct machine),1,fp)!=1) /*将一批数据作为一个整体一次性写入磁盘文件*/
|
|
|
|
|
|
|
|
printf("文件写入错误!\n");
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void printf_back()/*添加设备信息后显示的“是浏览还是返回”*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int w,k=0;
|
|
|
|
|
|
|
|
void browse();
|
|
|
|
|
|
|
|
void menu();
|
|
|
|
|
|
|
|
printf("\n\n\t^_^.插入成功. ^_^\n\n");
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("What do you want to do next?\n\n\t1).浏览所有\t2).返回: [ ]\b\b");
|
|
|
|
|
|
|
|
scanf("%d",&w);
|
|
|
|
|
|
|
|
if(w==1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
browse();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(w==2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
menu();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
printf(" 选择错误!请重新选择!\n");
|
|
|
|
|
|
|
|
}while(k==0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void insert() /*添加设备信息*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i,n,k,t;
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
if((fp=fopen("D:\\file.txt","rb"))==NULL) /*读入空文件,rb表示打开一个二进制文件,只允许读数据*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("How many machine do you want to add(1-%d)?:",N-1);
|
|
|
|
|
|
|
|
n=0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
n=load();
|
|
|
|
|
|
|
|
printf("How many student do you want to insert (1-%d)?:",N-n-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
scanf("%d",&t);
|
|
|
|
|
|
|
|
k=n+t;
|
|
|
|
|
|
|
|
for(i=n;i<k;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n输入第 %d 个实验设备信息.\n",i-n+1);
|
|
|
|
|
|
|
|
input(i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
save(k); /*保存所有设备的信息*/
|
|
|
|
|
|
|
|
printf_back();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void deleter() /*删除*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
void menu();
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
struct machine s;
|
|
|
|
|
|
|
|
int i,n,k,w0,w1;
|
|
|
|
|
|
|
|
n=load();
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
k=-1;//printf_n(n); /*删除之前先显示所有设备的信息*/
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\n请输入您想要删除的设备的名称!\nName:");
|
|
|
|
|
|
|
|
scanf("%s",s.name);
|
|
|
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
|
|
|
if(strcmp(s.name,stu[i].name)==0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
k=i;
|
|
|
|
|
|
|
|
s=stu[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(k==-1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int m;
|
|
|
|
|
|
|
|
printf("\n\n没有这个设备的信息!\n");
|
|
|
|
|
|
|
|
printf("What do you want to do next? 1.继续输入 2.返回主菜单 [ ]\b\b");
|
|
|
|
|
|
|
|
scanf("%d",&m);
|
|
|
|
|
|
|
|
if(m==1)
|
|
|
|
|
|
|
|
deleter();
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
k=0;
|
|
|
|
|
|
|
|
menu();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}while(k==-1);
|
|
|
|
|
|
|
|
printf_one(k);
|
|
|
|
|
|
|
|
printf("\n\t确定删除?\n\t1).是 2).返回 [ ]\b\b");/*再次询问是否删除*/
|
|
|
|
|
|
|
|
scanf("%d",&w0);
|
|
|
|
|
|
|
|
if(w0==1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
stu[k].name[0]='\0';
|
|
|
|
|
|
|
|
save(n);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
printf("\n\t^_^.成功删除^_^.\n");
|
|
|
|
|
|
|
|
printf("What do you want to do?\n\t1).继续 2).返回 [ ]\b\b");
|
|
|
|
|
|
|
|
scanf("%d",&w1);
|
|
|
|
|
|
|
|
}while(w1==1);
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
menu(); /*不再删除时返回主菜单,w1!=1*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void search() /*查找*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
void menu();
|
|
|
|
|
|
|
|
int w0,k,i,n,w1,w2;
|
|
|
|
|
|
|
|
struct machine s;
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
if((fp=fopen("D:\\file.txt","rb"))!=NULL) /*不是空文件*/
|
|
|
|
|
|
|
|
n=load();
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("请选择查找类别: 1.名称 2.编号 [ ]\b\b");
|
|
|
|
|
|
|
|
scanf("%d",&w1);
|
|
|
|
|
|
|
|
if(w1<1||w1>2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("输入错误!请重新输入!\n");
|
|
|
|
|
|
|
|
w2=1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
w2=0; /*这里要注意:不加这句话会陷入死循环,跳不出来*/
|
|
|
|
|
|
|
|
}while(w2==1);
|
|
|
|
|
|
|
|
if(w1==1) /*按名称查找*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
k=-1;
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n请输入您想要查找的设备的名称!\nName:");
|
|
|
|
|
|
|
|
scanf("%s",s.name);
|
|
|
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
|
|
|
if(strcmp(s.name,stu[i].name)==0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
k=i;
|
|
|
|
|
|
|
|
s=stu[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(k==-1) /*没有找到*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int o;
|
|
|
|
|
|
|
|
printf("\n\n没有这台设备的信息!\n!");
|
|
|
|
|
|
|
|
printf("What do you want to do?\n\t1.继续 2.返回菜单 [ ]\b\b");
|
|
|
|
|
|
|
|
scanf("%d",&o);
|
|
|
|
|
|
|
|
if(o==1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
search(); /*继续查找*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
menu();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}while(k==-1);
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
printf_one(k); /*找到以后输出这台设备的信息*/
|
|
|
|
|
|
|
|
printf("\nWhat do you want to do next?\n\t1).继续 2).返回菜单 [ ]\b\b");
|
|
|
|
|
|
|
|
scanf("%d",&w0);
|
|
|
|
|
|
|
|
}while(w0==1);
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
menu(); /*不再查找时返回主菜单*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else /*按编号查找*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
k=-1;
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n请输入您想要查找的设备的编号!\nNum:");
|
|
|
|
|
|
|
|
scanf("%s",s.num);
|
|
|
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
|
|
|
if(strcmp(s.num,stu[i].num)==0) /*找到了*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
k=i;
|
|
|
|
|
|
|
|
s=stu[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(k==-1) /*没有找到*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int o;
|
|
|
|
|
|
|
|
printf("\n\n没有这台设备的信息!\n!");
|
|
|
|
|
|
|
|
printf("What do you want to do?\n\t1.继续 2.返回菜单 [ ]\b\b");
|
|
|
|
|
|
|
|
scanf("%d",&o);
|
|
|
|
|
|
|
|
if(o==1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
search(); /*继续查找*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
menu();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}while(k==-1);
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
printf_one(k); /*找到以后输出这个设备的信息*/
|
|
|
|
|
|
|
|
printf("\nWhat do you want to do?\n\t1).继续 2).返回菜单 [ ]\b\b");
|
|
|
|
|
|
|
|
scanf("%d",&w0);
|
|
|
|
|
|
|
|
}while(w0==1);
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
menu();/*不再查找时返回主菜单*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int modify_data(int i) /*修改信息函数*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int c,w1;
|
|
|
|
|
|
|
|
void menu();
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
puts("\n请选择要修改的选项:\n\n1.编号 2.名称 3.种类 4价格 5.购买日期 6.是否报废 7.报废时间 8.处理方式 9.损耗费用");
|
|
|
|
|
|
|
|
printf("请选择?: [ ]\b\b\b");
|
|
|
|
|
|
|
|
scanf("%d",&c);
|
|
|
|
|
|
|
|
if(c>12||c<1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
puts("\n选择错误!请重新选择!");
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}while(c>12||c<1);
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
switch(c)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1: printf("编号:"); scanf("%s",stu[i].num); break;
|
|
|
|
|
|
|
|
case 2: printf("名称:"); scanf("%s",stu[i].name); break;
|
|
|
|
|
|
|
|
case 3: printf("种类:"); scanf("%s",stu[i].kind);break;
|
|
|
|
|
|
|
|
case 4: printf("价格:"); scanf("%s",stu[i].price); break;
|
|
|
|
|
|
|
|
case 5: printf("购买日期:"); scanf("%d/%d/%d",&stu[i].birthday.year,&stu[i].birthday.month,&stu[i].birthday.day); break;
|
|
|
|
|
|
|
|
case 6: printf("是否报废:"); scanf("%s",stu[i].yesno);break;
|
|
|
|
|
|
|
|
case 7: printf("报废时间:"); scanf("%d/%d/%d",&stu[i].time.year,&stu[i].time.month,&stu[i].time.day);break;
|
|
|
|
|
|
|
|
case 8: printf("处理方式:"); scanf("%s",stu[i].way); break;
|
|
|
|
|
|
|
|
case 9: printf("损耗:"); scanf("%s",stu[i].lost); break;
|
|
|
|
|
|
|
|
case 10: input(i); break; /*修改这个设备的所有信息*/
|
|
|
|
|
|
|
|
case 11: menu(); /*返回主菜单*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
puts("\nNow:\n");
|
|
|
|
|
|
|
|
printf_one(i); /*输出 修改后 的这个设备的信息*/
|
|
|
|
|
|
|
|
printf("\n确定?\n\n\t1).是 2).不,重新修改 3).返回不保存 [ ]\b\b");
|
|
|
|
|
|
|
|
scanf("%d",&w1);
|
|
|
|
|
|
|
|
}while(w1==2);
|
|
|
|
|
|
|
|
return(w1); /*修改成功并选择1后返回1*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void modify() /*修改*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
void menu();
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
struct machine s;
|
|
|
|
|
|
|
|
int i,n,k,w0=1,w1,w2=0;
|
|
|
|
|
|
|
|
n=load();
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
k=-1;
|
|
|
|
|
|
|
|
//printf_n(n); /*删除之前先显示所有设备的信息*/
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n请输入您想要修改的设备的名称!\nName:");
|
|
|
|
|
|
|
|
scanf("%s",s.name);
|
|
|
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
|
|
|
if(strcmp(s.name,stu[i].name)==0) /*与其中一个设备匹配*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
k=i;
|
|
|
|
|
|
|
|
s=stu[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(k==-1) /*没有找到输入的设备*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int o;
|
|
|
|
|
|
|
|
printf("\n\n没有这台设备的信息!\n");
|
|
|
|
|
|
|
|
printf("What do you want to do?\n\t1.继续 2.返回菜单 [ ]\b\b");
|
|
|
|
|
|
|
|
scanf("%d",&o);
|
|
|
|
|
|
|
|
if(o==1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
modify(); /*继续修改*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
menu();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}while(k==-1);
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
printf_one(k); /*输出这个设备的信息*/
|
|
|
|
|
|
|
|
w1=modify_data(k);
|
|
|
|
|
|
|
|
if(w1==1) /*判断是否修改成功修改*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\t^_^.修改成功 ^_^.\n\n是否继续?\n\n\t1).是 2).保存返回\t[ ]\b\b");
|
|
|
|
|
|
|
|
scanf("%d",&w0);
|
|
|
|
|
|
|
|
w2=1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
w0=0;
|
|
|
|
|
|
|
|
if(w2==0)
|
|
|
|
|
|
|
|
stu[k]=s;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if((w0!=1)&&(w2==1)) /*修改成功保存*/
|
|
|
|
|
|
|
|
save(n);
|
|
|
|
|
|
|
|
}while(w0==1);
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
menu();/*不再修改返回主菜单*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void browse()/*浏览*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("color 5f");
|
|
|
|
|
|
|
|
void menu();
|
|
|
|
|
|
|
|
int n;
|
|
|
|
|
|
|
|
n=load();
|
|
|
|
|
|
|
|
printf_n(n);
|
|
|
|
|
|
|
|
printf(" 共有 %d 个设备的记录.\n",n);
|
|
|
|
|
|
|
|
printf("\nPress [ ENTER ] key to back...");
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
menu(); /*返回主函数*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void exit() /*退出*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void menu() /*主菜单*/
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("color 2e");
|
|
|
|
|
|
|
|
printf("\n\t\t\t欢迎使用实验设备管理系统!\n");
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
int n,w1;
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
puts("\t\t★★★★★★★★ 菜单 ★★★★★★★★");
|
|
|
|
|
|
|
|
puts("\t\t★ 1.插 入 ★");
|
|
|
|
|
|
|
|
puts("\t\t★ 2.删 除 ★");
|
|
|
|
|
|
|
|
puts("\t\t★ 3.查 找 ★");
|
|
|
|
|
|
|
|
puts("\t\t★ 4.修 改 ★");
|
|
|
|
|
|
|
|
puts("\t\t★ 5.浏 览 ★");
|
|
|
|
|
|
|
|
puts("\t\t★ 7.退 出 ★");
|
|
|
|
|
|
|
|
puts("\t\t★★★★★★★★★★★★★★★★★★★★★");
|
|
|
|
|
|
|
|
printf("请选择服务种类(1-7) : [ ]\b\b");
|
|
|
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
|
|
|
if(n<1||n>7)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
printf("选择错误! 请重新选择!\n");
|
|
|
|
|
|
|
|
w1=1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
w1=0;
|
|
|
|
|
|
|
|
}while(w1==1);
|
|
|
|
|
|
|
|
switch(n)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1: system("cls"); insert(); break; /*插入*/
|
|
|
|
|
|
|
|
case 2: system("cls"); deleter(); break; /*删除*/
|
|
|
|
|
|
|
|
case 3: system("cls"); search(); break; /*查找*/
|
|
|
|
|
|
|
|
case 4: system("cls"); modify(); break; /*修改*/
|
|
|
|
|
|
|
|
case 5: system("cls"); browse(); break; /*浏览*/
|
|
|
|
|
|
|
|
case 7: exit(); break; /*退出*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
menu();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|