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.

402 lines
12 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include<stdio.h>
#include<string.h>
#include<windows.h>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<dos.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=21;
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, "书架A区");
book[0].base=19;
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, "书架B区");
book[1].base=9;
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, "书架C区");
book[2].base=49;
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, "书架D区");
book[3].base=39;
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, "书架E区");
book[4].base=29;
strcpy( book[5].title,"《平凡的世界》");
strcpy( book[5].author, "路遥");
strcpy( book[5].publice, "北京十月文艺出版社");
strcpy( book[5].time, "2017年6月1日");
book[5].price=29.90;
strcpy( book[5].locate, "二楼302");
book[5].base=50;
strcpy( book[6].title,"《老人与海》");
strcpy( book[6].author, "海明威");
strcpy( book[6].publice, "作家出版社");
strcpy( book[6].time, "2016年1月1日");
book[6].price=13.10;
strcpy( book[6].locate, "二楼302");
book[6].base=50;
strcpy( book[7].title,"《神曲》");
strcpy( book[7].author, "但丁");
strcpy( book[7].publice, "上海译文出版社");
strcpy( book[7].time, "2011年1月1日");
book[7].price=29.90;
strcpy( book[7].locate, "二楼302");
book[7].base=50;
strcpy( book[8].title,"《骆驼祥子》");
strcpy( book[8].author, "老舍");
strcpy( book[8].publice, "浙江工商大学出版社");
strcpy( book[8].time, "2017年8月1日");
book[8].price=16.30;
strcpy( book[8].locate, "二楼302");
book[8].base=50;
strcpy( book[9].title,"《朝花夕拾》");
strcpy( book[9].author, "鲁迅");
strcpy( book[9].publice, "台海出版社");
strcpy( book[9].time, "2012年8月1日");
book[9].price=22.40;
strcpy( book[9].locate, "二楼302");
book[9].base=50;
strcpy( book[10].title,"《茶花女》");
strcpy( book[10].author, "小仲马");
strcpy( book[10].publice, "西安交通大学出版社");
strcpy( book[10].time, "2017年8月1日");
book[10].price=10.10;
strcpy( book[10].locate, "二楼302");
book[10].base=50;
strcpy( book[11].title,"《傲慢与偏见》");
strcpy( book[11].author, "奥斯丁");
strcpy( book[11].publice, "西安交通大学出版社");
strcpy( book[11].time, "2017年1月1日");
book[11].price=15.50;
strcpy( book[11].locate, "二楼302");
book[11].base=50;
strcpy( book[12].title,"《红与黑》");
strcpy( book[12].author, "斯当达");
strcpy( book[12].publice, "西安交通大学出版社");
strcpy( book[12].time, "2017年7月1日");
book[12].price=18.90;
strcpy( book[12].locate, "二楼302");
book[12].base=50;
strcpy( book[13].title,"《罪与罚》");
strcpy( book[13].author, "陀思妥耶夫斯基");
strcpy( book[13].publice, "西安交通大学出版社");
strcpy( book[13].time, "2016年11月10日");
book[13].price=27.20;
strcpy( book[13].locate, "二楼302");
book[13].base=50;
strcpy( book[14].title,"《战争与和平》");
strcpy( book[14].author, "列夫·托尔斯泰");
strcpy( book[14].publice, "西安交通大学出版社");
strcpy( book[14].time, "2016年11月1日");
book[14].price=56.70;
strcpy( book[14].locate, "二楼302");
book[14].base=50;
strcpy( book[15].title,"《巴黎圣母院》");
strcpy( book[15].author, "雨果");
strcpy( book[15].publice, "上海文艺出版社");
strcpy( book[15].time, "2008年1月1日");
book[15].price=14.10;
strcpy( book[15].locate, "二楼302");
book[15].base=50;
strcpy( book[16].title,"《家》");
strcpy( book[16].author, "巴金");
strcpy( book[16].publice, "人民文学出版社");
strcpy( book[16].time, "1981年9月1日");
book[16].price=24.10;
strcpy( book[16].locate, "二楼302");
book[16].base=50;
strcpy( book[17].title,"《边城》");
strcpy( book[17].author, "沈从文");
strcpy( book[17].publice, "北京十月文艺出版社");
strcpy( book[17].time, "2018年8月1日");
book[17].price=19.70;
strcpy( book[17].locate, "二楼302");
book[17].base=50;
strcpy( book[18].title,"《红岩》");
strcpy( book[18].author, "罗广斌");
strcpy( book[18].publice, "中国青年出版社");
strcpy( book[18].time, "2017年9月1日");
book[18].price=22.70;
strcpy( book[18].locate, "二楼302");
book[18].base=50;
strcpy( book[19].title,"《呐喊》");
strcpy( book[19].author, "鲁迅");
strcpy( book[19].publice, "安徽教育出版社");
strcpy( book[19].time, "2015年1月1日");
book[19].price=15.40;
strcpy( book[19].locate, "二楼302");
book[19].base=50;
strcpy( book[20].title,"《活着》");
strcpy( book[20].author, "余华");
strcpy( book[20].publice, "作家出版社");
strcpy( book[20].time, "2012年8月1日");
book[20].price=15.30;
strcpy( book[20].locate, "二楼302");
book[20].base=50;
struct user
{
char user_name[100];
char user_pass[100];
} stu[2]= {{"xiaocong001","123456"},{"zhuzhu002","123456"}};
int num1=0;
int num2=0;
int w=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[20];
char ch=0;
int j=0;
int x=6;
int q=0;
while(x>0&&(ch=getch())!='\r')
{
if(ch=='\b')
{
if(j>0)
{
printf("\b \b");
q--;
j--;
}
else
{
printf("\a");
continue;
}
x++;
}
else
{
putchar('*');
p[q]=ch;
q++;
x--;
j++;
}
}
p[6]='\0';
if(strcmp(stu[0].user_pass,p)==0)
{
printf(" 登录成功\n");
break;
}
else
{
if(num2!=2)
{
printf("\n 密码错误,请重新输入:");
}
num2++;
if(num2==3)
{
printf("\n");
printf("密码输入错误超过三次系统3秒后将关闭\n");
Sleep(1000);
printf("3\n");
Sleep(1000);
printf("2\n");
Sleep(1000);
printf("1\n");
exit(0);
}
}
}
system("cls"); //清屏
system("color e5");
char t[20],a[20];
int i;
float sum[100]= {0};
while(1)
{
int n=0;
int j=0;
printf("\t\t***************************************\n");
printf("\t\t*如需退出输入带有'*'的任意两个字符串。*\n");
printf("\t\t*eg:'* *' *\n");
printf("\t\t***************************************\n\n\n");
printf("请输入您要搜寻的书名与著者:\n") ;
scanf("%s%s",&t,&a);
if((*t=='*')||(*a=='*'))
{
printf("\t\t请求退出系统成功\n");
break;
}
for(i=0; i<21; i++)
{
if((strcmp(t,book[i].title)==0)||strcmp(t,book[i].author)==0)
{
if((strcmp(a,book[i].author)==0)||strcmp(a,book[i].title)==0)
{
printf("\t|-----------------------------------\n");
printf("\t|***********书目在清单内***********|\n");
printf("\t|书名 :%20s |\n", book[i].title);
printf("\t|著者 :%20s |\n", book[i].author);
printf("\t|出版社 :%20s |\n", book[i].publice);
printf("\t|出版时间 :%20s |\n", book[i].time);
printf("\t|价格 :%20.2f |\n",book[i].price);
printf("\t|位置 :%20s |\n",book[i].locate);
printf("\t|库存 :%20d |\n",book[i].base);
printf("\t-----------------------------------|\n");
printf("请输入所需数量:");
int num;
int m=1;
while(m==1)
{
scanf("%d",&num);
if(num<0)
{
printf("输入有误.\n");
printf("请入正确的数值:");
}
else if(num<=book[i].base)
{
book[i].base=book[i].base - num;
printf("\n\n\t\t已选定%d 本 %s\n",num,book[i].title);
sum[i]=num*book[i].price;
printf("\t\t此次选定所需支付的金额:%.2f\n",sum[i]);
float s=0.0;
for(i=0; i<21; i++)
s+=sum[i];
printf("\t\t当前总金额:%.2f\n\n\n",s);
m=0;
}
else
{
printf("所需数量不在库存范围内\n");
printf("请输入库存以内的数量:");
}
}
n=1;
}
}
}
if(n==0)
{
printf("\t请输入正确的书名以及对应的作者。\n");
}
printf("\t\t*请继续挑选所需书籍。\t*\n\t\t*如果不需要请退出。\t*\n");
printf("\n");
}
float s=0.0;
for(i=0; i<21; i++)
s+=sum[i];
printf("\t\t\t\t总共需支付:%.2f\n",s);
Sleep(3000);
system("cls");
system("color f6");
Sleep(1000);
printf("\t\t\t\t欢迎下次光临深夜书店。\n");
Sleep(1000);
printf("\t\t\t\t书中搞不好没有黄金屋 千钟粟\n");
Sleep(1000);
printf("\t\t\t\t颜如玉\n");
Sleep(1000);
printf("\t\t\t\t可书店 有你啊");
return 0;
}