Current location - Training Enrollment Network - Books and materials - C language programming for bookstore book sales system
C language programming for bookstore book sales system
# contains "stdio.h"

# contains "string.h"

# Definition number 1000

Structural book

{ char author[ 10];

char bk name[20];

Floating price;

int num

};

int n;

Bkin (structure book bk[])

{

char ath[ 10],bknm[20];

Floating pr;

int nm,I;

clr SCR();

Printf ("Enter book name, book author price number: \ n");

Scanf("%s%s%f%d ",ath, bknm,&pr&);

for(I = 0; I & ltn;; i++)

if ( strcmp(bk[i].bkname,bknm)= = 0)break;

If (I & ltn) bk[i]. num+= nm;

other

{

Strcpy(bk[n]. Author, ath);

strcpy(bk[n].bkname,bknm);

bk[n]。 Price = pr

bk[n]。 num = nm

n++;

}

Printf ("The book is OK ... \ n");

}

Bksale (structure book bk[])

{

clr SCR();

Printf ("book sales ... \ n");

}

Bklist (structure book bk[])

{

int I;

clr SCR();

Printf ("Book List: \ n \ n");

Printf ("author's book name price book number \ n");

printf("-\ n ");

for(I = 0; I & ltn;; i++)

printf(" %- 10s %-20s %- 10.2 f %-5d \ n ",bk[i]。 Author,

bk[i]。 bkname,bk[i]。 Price, bk[i]. num);

}

Show ()

{ clr SCR();

printf(" \ n \ n \ n \ n ");

printf("-\ n ");

printf(" 1。 BookIn \ n ");

printf(" 2。 book sale \ n ");

printf(" 3。 Book list \ n ");

printf(" 4。 Exit \ n ");

printf("-\ n ");

Printf ("Please select1.2.3.4: \ n");

}

Master ()

{

Structure book bk [n];

int select

strcpy(bk[0])。 Author, "Tom");

strcpy(bk[0])。 bkname," bookname 1 ");

bk[0]。 Price = 20.00;

bk[0]。 num = 10;

strcpy(bk[ 1])。 Author, "Jerry");

strcpy(bk[ 1])。 bkname," bookname 2 ");

bk[ 1]。 Price =12.00;

bk[ 1]。 num = 3;

n = 2;

show();

Scanf("%d ",& select);

And (choose! = 4)

{ if(select = = 1)bkin(bk);

if(select = = 2)bk sale(bk);

if(select = = 3)bk list(bk);

getch();

show();

Scanf("%d ",& select);

}

}