Home > Back-end >  Why my linear table book information management code to run is not completed, save the children
Why my linear table book information management code to run is not completed, save the children

Time:10-09

#include
#include
#include
# define MAXSIZE 100
Typedef int the status;
Typedef struct
{char bname [100].
Char bno [100]. } the BOOK;
Typedef struct
{BOOK * elem;
int length;
Int listsize; } sqlist;

Int search (sqlist * l, BOOK e)
{the for (int I=0; IIf (STRCMP (e.b name, l - & gt; Elem [I] bname)==0)
return i+1;
return 0; }

Int locateElem (sqlist * l)
{int I;
I=l - & gt; Length;
return i; }

Int research (sqlist * l, BOOK e)
{the for (int I=0; IIf (STRCMP (e.b no, l - & gt; Elem [I] bno)==0)
return i+1;
return 0; }

The status init (sqlist * l)
{l - & gt; Elem=NULL;
L - & gt; Elem=(BOOK *) malloc (sizeof (BOOK) * MAXSIZE);
if(! L - & gt; Elem)
return 0;
L - & gt; length=0;
L - & gt; Listsize=MAXSIZE;
return 1; }

Void input (BOOK * e)
{
Printf (" please enter the book information: \ n ");
Printf (" title, isbn \ n ");
The scanf (" % s % s ", e - & gt; Bname, e - & gt; Bno); }

The status listinsert (sqlist * l, int & amp; I, the BOOK e)
{if (l - & gt; Length==MAXSIZE)
return 0;
If (i<1 | | i> L - & gt; Length + 1)
return 0;
For (int k=l - & gt; Length; K>=I - 1; K -)
L - & gt; Elem [k + 1)=l - & gt; Elem [k].
L - & gt; Elem] [I - 1=e;
+ + l - & gt; Length;
return 1; }

Status listdelete (sqlist * l, int I BOOK * e)
{if (l - & gt; Length==0) return 0;
If ((i<1) | | (i> L - & gt; Length)) return 0;
* e=l - & gt; Elem [I - 1);
For (int k=I; K<=l - & gt; Length - 1. K++)
L - & gt; Elem] [k - 1=l - & gt; Elem [k].
- l - & gt; Length;
return 1; }

Void change (sqlist * l, BOOK e)
{the for (int I=0; I{if (strcpy (e.b name, l - & gt; Elem [I] bname)==0)
Strcpy (l - & gt; Elem [I]. Bno, e.b no); }}

Void the output (the BOOK * e)
{
Printf (" % s % s ", e - & gt; Bname, e - & gt; Bno);
printf("\n"); }

Int main ()
{sqlist l;
The BOOK e, b, d, c;
Int I, j, a, g, f;
Init (& amp; L);
Printf (" please enter the number of books \ n ");
The scanf (" % d ", & amp; a);
for(i=0; IInput (& amp; L.e lem [I]);
Printf (" please enter the need to insert elements and seat: \ n ");
The scanf (" % s % s ", & amp; B.b name, & amp; B.b no);
The scanf (" % d ", & amp; i);
Listinsert (& amp; L, I, b);
Printf (" please enter to delete elements table: \ n ");
The scanf (" % d ", & amp; J);
Listdelete (& amp; L, j, l.e lem);
Printf (" please enter the need to find the isbn \ n ");
The scanf (" % s ", & amp; E.b no);
G=research (& amp; L, e);
Printf (" table for long: \ n ");
LocateElem (& amp; L);
Printf (" please enter the need to find the title of \ n ");
The scanf (" % s ", & amp; Db name);
F=search (& amp; L, d);
Printf (" please input to modify the title of the book: \ n ");
The scanf (" % s ", & amp; Mount name);
Printf (" please enter a number changes: \ n ");
Printf (" % s ", & amp; Mount no);
Change (& amp; L, c);
for(i=0; IThe output (& amp; L.e lem [I]);
return 0; }
  • Related