Current location - Training Enrollment Network - Books and materials - Program design of book management
Program design of book management
# include & ltiostream & gt

# include & ltstring.h & gt

Use namespace std

Classroom books

{

Public:

char ID[20];

char name _ 1[ 15];

char name _ 2[ 15];

char writer[ 15];

char press[ 15];

Billing date [15];

Invalid set ()

{cout & lt& lt "Please enter the book number"

CIN & gt; & gtID;

Cout & lt& lt "Please enter a book name"

CIN & gt; & gtname _ 1;

Cout & lt& lt "Please enter the author's name" < & ltendl

CIN & gt; & gtname _ 2;

Cout & lt& lt "Please enter the name of the publisher"

CIN & gt; & gt news;

Cout & lt& lt "Please enter the publication date"

CIN & gt; & gt date;

}

Empty display ()

{ int j;

Cout & lt& lt "No."

Cout & lt& lt "Author:"

for(j = 0; j & lt70; j++)

cout & lt& lt"_";

cout & lt& ltendl

}

};

Int search (char a[ 15], char b[ 15])

{

char c[ 100],* p;

int m,n,I,w = 0;

m = strlen(a);

n = strlen(b);

for(I = 0; I< = m-n; i++)

{

for(p = & amp; a[I]; p & lta+I+n; p++)

{

c[w++]= * p;

}

c[w]= ' \ 0 ';

if (strcmp(b,c)==0)

Returns1;

w = 0;

}

Returns 0;

}

int I =- 1;

void main()

{ int n,j,t = 0;

char c;

char d[ 15];

Book b [20];

And (n! =4)

{cout & lt& lt "Please enter the action you want to perform:"

Cout & lt& lt" 1 entry book "

CIN & gt; & gtn;

Switch (n)

{Case 1:

do

{ i++;

b[i]。 set();

Cout & lt& lt "Continue typing? (Yes/No) ";

CIN & gt; & gtc;

}

while(c = = ' Y ' | | c = = ' Y ');

Break;

Case 2:

{

for(j = 0; j & lt70; j++)

cout & lt& lt"_";

cout & lt& ltendl

for(j = 0; j & ltI+ 1; j++)

{

for(int k = j; k & ltI+ 1; k++)

if(strcmp(b[j].name_ 1,b[k+ 1]。 name_ 1)>0)

{

Book m;

m = b[j];

b[j]= b[k+ 1];

b[k+ 1]= m;

}

}

for(j = 0; j & ltI+ 1; j++)

b[j]。 Display ();

} broken;

Case 3:

{

Cout & lt& lt "Please enter the author's name:";

CIN & gt; & gtd;

for(j = 0; j & ltI+ 1; j++)

{

If (search (d, b[j]). name_2))

{

t++;

b[j]。 Display ();

}

}

Cout & lt& lt "discovery"

t = 0;

}

}

}

}

Easy to use and sorted by title