You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
160 lines
3.7 KiB
160 lines
3.7 KiB
#include<stdio.h>
|
|
#include<string.h>
|
|
#include<windows.h>
|
|
#include<math.h>
|
|
#include<stdlib.h>
|
|
#include<time.h>
|
|
#include<dos.h>
|
|
#include<conio.h>
|
|
int main()
|
|
{
|
|
system("color f4");
|
|
struct BOOK
|
|
{
|
|
char title[20];
|
|
char author[20];
|
|
char publice[20];
|
|
char time[20];
|
|
float price;
|
|
char locate[20];
|
|
int base;
|
|
//书籍名称,作者,出版社,出版日期,价格,在目录中的位置
|
|
};
|
|
|
|
struct BOOK *book;
|
|
int N=5;
|
|
book=(struct BOOK*)malloc(N*sizeof(struct BOOK));
|
|
strcpy( book[0].title, "《浪潮之巅》");
|
|
strcpy( book[0].author, "吴军");
|
|
strcpy( book[0].publice, "人民邮电出版社");
|
|
strcpy( book[0].time, "2016年5月1日");
|
|
book[0].price=99.00;
|
|
strcpy( book[0].locate, "二楼302");
|
|
book[0].base=50;
|
|
|
|
strcpy( book[1].title, "《人间失格》");
|
|
strcpy( book[1].author, "太宰治");
|
|
strcpy( book[1].publice, "现代出版社");
|
|
strcpy( book[1].time, "2016年10月");
|
|
book[1].price=26.00;
|
|
strcpy( book[1].locate, "二楼302");
|
|
|
|
strcpy( book[2].title, "《围城》");
|
|
strcpy( book[2].author, "钱钟书");
|
|
strcpy( book[2].publice, "上海晨光出版社");
|
|
strcpy( book[2].time, "1947年");
|
|
book[2].price=40.00;
|
|
strcpy( book[2].locate, "二楼302");
|
|
|
|
strcpy( book[3].title, "《红高粱家族》");
|
|
strcpy( book[3].author, "莫言");
|
|
strcpy( book[3].publice, "人民文学出版社");
|
|
strcpy( book[3].time, "2007年1月");
|
|
book[3].price=28.00;
|
|
strcpy( book[3].locate, "二楼302");
|
|
|
|
strcpy( book[4].title, "《百年孤独》");
|
|
strcpy( book[4].author, "加西亚·马尔克斯");
|
|
strcpy( book[4].publice, "新经典文化");
|
|
strcpy( book[4].time, "2011年6月");
|
|
book[4].price=39.50;
|
|
strcpy( book[4].locate, "二楼302");
|
|
|
|
|
|
|
|
|
|
struct user
|
|
{
|
|
char user_name[100];
|
|
char user_pass[100];
|
|
}stu[2]={{"xiaocong001","123456"},{"zhuzhu002","123456"}};
|
|
int num1=0;
|
|
int num2=0;
|
|
printf("***************欢迎来到深夜书店存货清单管理系统登录界面***************\n"); //登录系统
|
|
while(1)
|
|
{
|
|
printf("\t\t请输入您的用户名:");
|
|
char u[100];
|
|
|
|
scanf("%s",u);
|
|
|
|
if(strcmp(stu[0].user_name,u)==0||strcmp(stu[1].user_name,u)==0)
|
|
{
|
|
break;
|
|
}
|
|
|
|
else{
|
|
printf("不存在此用户!请重新输入!\n");
|
|
num1++;
|
|
if(num1==3)
|
|
{
|
|
printf("\n\t\t很抱歉,您没有权限进入系统!\n");
|
|
exit(0); }
|
|
}
|
|
}
|
|
system("cls");
|
|
printf("***************欢迎来到深夜书店存货清单管理系统登录界面***************\n");
|
|
printf("\t\t请输入密码:");
|
|
while(1)
|
|
{
|
|
char p[100];
|
|
scanf("%s",p);
|
|
if(strcmp(stu[0].user_pass,p)==0)
|
|
{
|
|
printf(" 登录成功\n");
|
|
break;
|
|
}else
|
|
{
|
|
printf(" 密码错误,请重新输入");
|
|
num2++;
|
|
if(num2==3)
|
|
{
|
|
printf("密码输入错误超过三次,系统即将关闭");
|
|
exit(0);
|
|
}
|
|
}
|
|
}
|
|
system("cls"); //刷屏
|
|
system("color e5");
|
|
|
|
|
|
|
|
|
|
char t[20],a[20];
|
|
int i;
|
|
|
|
printf("请输入您要寻找的书名和作者\n") ;
|
|
scanf("%s%s",&t,&a);
|
|
for(i=0;i<5;i++)
|
|
{
|
|
if((strcmp(t,book[i].title)==0))
|
|
{
|
|
if((strcmp(a,book[i].author)==0))
|
|
{
|
|
printf("The book is in the list.");
|
|
printf( "书名 : %s\n", book[i].title);
|
|
printf( "作者 : %s\n", book[i].author);
|
|
printf( "出版社 : %s\n", book[i].publice);
|
|
printf( "出版时间 : %s\n", book[i].time);
|
|
printf("库存\n");
|
|
printf("请输入所需数量:");
|
|
int n;
|
|
scanf("%d",&n);
|
|
if(n>(book[i].base))
|
|
{
|
|
printf("所需数量不在库存范围内");
|
|
}
|
|
else
|
|
{
|
|
book[i].base=book[i].base - n;
|
|
printf("已选定%d 本 %s\n",n,book[i].title);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|