小精灵钢琴谱带指法:急求编程》高手进!!

来源:百度文库 编辑:高考问答 时间:2024/04/29 20:27:57
书店售书管理系统

要求:

1.书入库登记:书名、作者名、出版社、定价、入库数。

2.图书销售管理:增减相关库存数,计算顾客购买图书总价,应收金额、顾客实付现金,以
及找零。

3.图书库存查询:可按作者姓名,或者书名,或者出版社查询。

4.图书预定功能:包含作者姓名、书名以及出版社,图书数量、顾客联系电话。
能编的话联系我啊!secondwindcj@163.com 谢谢!明天检查了!!!

#include"stdio.h"
#include"math.h"
#include"string.h"
#define N 10
struct book
{char num[10];
char name[15];
char author[15];
char press[15];
float price;
int sum;
}book[N],new,sell;
main()
\n");
printf("*-----------------------------------------------------*\n");
printf("please choose the kind of serve.\n");
L1:choice=getchar();
if(choice=='e'||choice=='E')break;
switch(choice)
{
case 'B': case 'b':
breg();break;
case 'S':case 's':
sman();break;
case 'I':case 'i':
inqur();break;
case 'R':case 'r':
reserve();break;
default:putchar('\b');
printf("please entre your choice.\n");
goto L1;
}
/*printf("press anykey to continue.\n");
printf("press 'e'to exie.\n");
printf("Enter0 your choice.\n");
goto L1;*/
}
}

void breg()
{FILE *fp;
int i,j,n; char c='y';fp=fopen("book","w");fclose(fp);
printf("please input the kinds of new books.\n");
scanf("%d",&n);
printf("are you first input ?(Y/N)\n");
scanf("%c",&c);
if(c=='Y'||c=='y')
{fp=fopen("book","w");
if(fp==NULL){printf("can'topen file\n");exit(0);}
printf("\n NO name author press price sum \n");
for(i=0;i<n;i++)
{printf("please input the new book message.\n");
scanf("%s%s%s%s%f%d",book[i].num,book[i].name,book[i].author,book[i].press,&book[i].price,&book[i].sum);
if(fwrite(&book[i],sizeof(struct book),1,fp)!=1)
printf("file write error\n");
}
fclose(fp);
}
else if(c=='N'||c=='n')
{if((fp=fopen("book","r+"))==NULL)
{printf("can't open file\n");
exit(0);
}
for(i=0;i<n;i++)
{printf("input the message\n");
printf("NO name author press price sum\n");
scanf("%s%s%s%s%f%d",new.num,new.name,new.author,new.press,&new.price,&new.sum);
for(j=0;fread(&book[j],sizeof(struct book),1,fp)!=0;j++)
if(strcmp(book[j].name,new.name)==0)
book[j].sum+=new.sum;
else
if(fwrite(&book[j],sizeof(struct book),1,fp)!=1)
printf("write file error.\n");
}
fclose(fp);
}
else
printf("error\n");
}

void sman()
{float price,give,z=9.0;
static float sum=0.0;
int i,n;
char h,name[15],c='a';
FILE *fp;
if((fp=fopen("book","r"))==NULL)
{printf("can't open file.\n");
exit(0);
}
while(c!='e'&&c!='E')
{ printf("input the name and sum of book.\n");
scanf("%s%d",name,&n);
for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)
{if(name==book[i].name)
{sum+=book[i].price*n;book[i].sum-=n;}
else
{printf("please input price.\n");
scanf("%f",&price);
sum+=price*n;
}
printf("press any key to continue press'e' to stop\n");
c=getchar();
}
fclose(fp);
printf("are you a menbershipe.(Y/N)\n");
h=getchar();
if(h=='Y'||h=='y')
{printf("da %f zhe \n",z);
sum=sum*z/10;
printf("you should pay %fyuan.\n",sum);
}
else
printf("you should pay %f yuan.\n",sum);
printf("how much you give?\n");
scanf("%f", &give);
printf("should give you chage is %fyuan.\n",give-sum);
}
}

#include"stdio.h"
#include"math.h"
#include"string.h"
void inqur()

{FILE *fp;
int i;
char c,name[15],author[15],press[15];
printf("please choose the means to inqure.\n");
printf("N--name\n");
printf("A--author\n");
printf("P--press\n");
c=getchar();
if((fp=fopen("book","r"))==NULL)
{printf("can't open file.\n");
exit(0);
}

for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)
switch(c)
{case 'n':case 'N':
{printf("please input the name of book.\n");
scanf("%s",name);
if(strcmp(name,book[i].name)==0)
printf("massage:\n%8s%8s%8s%8s%8f%8d\n",book[i].num,book[i].name,book[i].author,book[i].press,book[i].price,book[i].sum);
else
printf("can't find !\n");
break;
}

case 'a':case 'A':
{printf("please input the author of book.\n");
scanf("%s",author);
if(strcmp(author,book[i].author)==0)
printf("massage:\n%8s%8s%8s%8s%8f%8d\n",book[i].num,book[i].name,book[i].author,book[i].press,book[i].price,book[i].sum);
else
printf("can't find !\n");
break;
}

case 'p':case 'P':
{printf("please input the press of book.\n");
scanf("%s",press);
if(strcmp(press,book[i].press)==0)
printf("massage:\n%8s%8s%8s%8s%8f%8d\n",book[i].num,book[i].name,book[i].author,book[i].press,book[i].price,book[i].sum);
else
printf("can't find !\n");
break;
}
}
fclose(fp);
}

struct reserve
{char author[15];
char name[15];
char tele[10];
int sum;
}reor[N];
void reserve()
{FILE *fp;
int i,n;
if((fp=fopen("reserve","r+"))==NULL)
fp=fopen("reserve","w");
if(fp==NULL){printf("can't open file.\n");
exit(0);}
printf("please input yuor reservr books' kinds\n");
scanf("%d",&n);
printf("author name tele sum\n");
for(i=0;i<n;i++)
{printf("please give your reserve meassage.\n");
scanf("%s%s%S%d",reor[i].author,reor[i].name,reor[i].tele,reor[i].sum);
if(fwrite(&reor[i],sizeof(struct reserve),1,fp)!=1)
printf("file can't write.\n");
}
fclose(fp);
}