跪求c语言程序设计之书店图书销售系统
发布网友
发布时间:2024-07-02 07:14
我来回答
共2个回答
热心网友
时间:2024-08-24 22:48
#include "stdio.h"
#include "string.h"
#define N 1000
struct book
{char author[10];
char bkname[20];
float price;
int num;
};
int n;
bkin(struct book bk[])
{
char ath[10],bknm[20];
float pr;
int nm,i;
clrscr();
printf("Input BookName BookAuthor Price Number:\n");
scanf("%s%s%f%d",ath,bknm,&pr,&nm);
for (i=0;i<n;i++)
if ( strcmp(bk[i].bkname,bknm)==0 ) break;
if (i<n) bk[i].num+=nm;
else
{
strcpy(bk[n].author,ath);
strcpy(bk[n].bkname,bknm);
bk[n].price=pr;
bk[n].num = nm;
n++;
}
printf("Book In ok...\n");
}
bksale(struct book bk[])
{
clrscr();
printf("Book Sale....\n");
}
bklist(struct book bk[])
{
int i;
clrscr();
printf(" Book List:\n\n");
printf("Author BookName Price BookNumber\n");
printf("------------------------------------------------------\n");
for (i=0;i<n;i++)
printf("%-10s %-20s %-10.2f %-5d\n",bk[i].author,
bk[i].bkname,bk[i].price,bk[i].num);
}
show()
{clrscr();
printf("\n\n\n\n\n");
printf(" ----------------------------------------------------\n");
printf(" 1.BookIn\n");
printf(" 2.Booksale\n");
printf(" 3.BookList\n");
printf(" 4.Exit\n");
printf(" ----------------------------------------------------\n");
printf(" Please select 1.2.3.4:\n");
}
main()
{
struct book bk[N];
int select;
strcpy(bk[0].author,"Tom");
strcpy(bk[0].bkname,"Bookname1");
bk[0].price=20.00;
bk[0].num = 10;
strcpy(bk[1].author,"Jerry");
strcpy(bk[1].bkname,"Bookname2");
bk[1].price=12.00;
bk[1].num = 3;
n=2;
show();
scanf("%d",&select);
while(select != 4)
{ if (select == 1) bkin(bk);
if (select == 2) bksale(bk);
if (select == 3) bklist(bk);
getch();
show();
scanf("%d",&select);
}
}
热心网友
时间:2024-08-24 22:49
现在谁家也不缺孝子,又跪又求的,瞧这点出息!
-----------
可以应用百度Hi通知我
有时间可以解决你的问题
相关的要求也可以通知我
ES:\\B7E1FB855527554BED9D4CE9E2C21389
交易提醒:预付定金是陷阱