Home > Back-end >  Pray god to change next was not wrong
Pray god to change next was not wrong

Time:09-27

# include "stdio.h"
# include "stdlib. H"
Struct home
{
Char nember [20].
char name[20];
Char sex [10].
Char person [10].
Char time [10].
Char contain [10].
Char money [10].
Struct home * next;
The prior struct home *;
} the list_entry;
Struct home * start;
Struct home * last;
Void main ()
{
Char prompt; Char * s; Int count=10;
Void menu_select ();
Char * inputs (prompt, s);
Void the alter (); Void the search (); Void cost (); Void tuichu (); Void the enter ();
Void search1 ();
Void search2 ();
Void search3 ();
Void tongji ();
Void delet ();
Int b; Int I=1;
Struct home * info;
Start=0;
While (I)
{
The switch (menu_select ())
{
Case 1:
Enter ();
break; Case 2:
The alter ();
break;
Case 3:
Search ().
break;
Case 4:
Cost ();
break;
Case 5:
Delet ();
break;
Case 6:
Tongji ();
break;
Case 7:
Tuichu (); }
}
Void menu_select ()
{
Int c;
Printf (" \ \ t t=========================================================\ n ");
Printf (" \ \ t t=========================================================\ n "); Printf (" \ \ t t========hotel guest room management system \ n "); Printf (" \ \ t t========please select function \ n "); Printf (" \ \ t t====1 input guest room situation====\ n "); Printf (" \ \ t t=2 changing the room=======\ n "); Printf (" \ \ t t====3 room situation query====\ n "); Printf (" \ \ t t====4 rooms cost====\ n "); Printf ("====5 t \ \ t delete specified room====\ n "); Printf (" \ \ t t====6 statistical room situation====\ n "); Printf (" \ \ t t========7 exit system \ n "); Printf (" \ \ t t=========================================================\ n "); Printf (" \ \ t t=========================================================\ n "); Do {
Printf (" please press numeric choice \ n "); The scanf (" % d ", & amp; C); getchar();
While (c<0 | | c> 10); Return the c;
Void the enter ()
{struct info home * and * dls_store (); Char s [10]; Char a [10]="have". For (;; ) {
Info=(sturct home) malloc (1, sizeof (list_entry)); If (info==0)
{printf (" the memory has already finished with \ n "); return; }
Inputs (" \ n \ t room number ", info - & gt; Nember); if(! The info - & gt; Nember [0]) break;
The number of inputs (" can \ t \ n ", info - & gt; Contain);
Inputs (" \ t someone input have no input null \ n ", info - & gt; Person); if(! STRCMP (a, info - & gt; Person)) {
Inputs (" \ t name: \ n ", info - & gt; Name); Don't inputs (" \ t surname: \ n ", info - & gt; Sex);
Inputs (" \ t live into time: \ n ", info - & gt; Time); }
Inputs (" \ \ n "t someone input time when no one input, info - & gt; Time); Inputs (" \ t enter room costs \ n ", info - & gt; Money); Start=dls_store (info, start); }}
Char * inputs (prompt, s)
{
Char [255] p;
Do {
The printf (prompt); gets(p);
If (strlen (p) & gt; The count) printf (" too long \ n "); } while (strlen (p) & gt; The count); Strcpy (s, p); }

Void the alter ()
{
Struct info home * and * a find ();
Char roomNO [20]. Char a [10]="have". Char c [10]="null"; Int b;
Printf (" \ t want to check out room is input 1 \ n "); Printf (" \ t want to modify the input 2 \ n "); Printf (" \ t don't want to modify the input 3 \ n "); The scanf (" % d ", & amp; B); If (b==1) the search (); If (b==2) {
Printf (" \ t for room number please enter \ n "); The scanf (" % s ", nember); getchar();
if(! (info=find (nember))) printf (" \ t didn't find \ n "); The else {
The display (info); Printf (" \ n \ t here is to modify the project "); if(! STRCMP (a, info - & gt; Person))
Inputs (" \ t enter null: \ n ", info - & gt; Person, 10); if(! STRCMP (c, info - & gt; Person)) {
Inputs (" \ t \ n ", please enter the name and info - & gt; The name, 10); Inputs (" please enter the gender \ n \ t ", info - & gt; Sex, 10); Inputs (" \ \ n "t please enter time, info - & gt; Time, 10); }}}
If (b==3) return; }
Struct home * find (char * nember nember);
{struct home * info; Info=start; While (info) {
if(! STRCMP (nember, info - & gt; Nember)) return the info; Info=info - & gt; next; }
Printf (" \ t didn't find \ n "); Return (NULL);
}
The display (info)
Struct home * info;
{char a [10]="have".
Printf (" \ n \ t room number: % s ", info - & gt; Nember); Printf (" can \ t live toll: % s \ n ", info - & gt; Contain);
Printf (" \ t no live display null when someone lives have: % s \ n ", info - & gt; Person); if(! STRCMP (a, info - & gt; Person)) {
Printf (" % s \ n \ t name ", info - & gt; Name); Printf (" % s \ n \ t sex ", the info - & gt; Sex); Printf (" % s \ n \ t time ", the info - & gt; Time); }
Printf (" \ t room daily expenses: % s \ n ", info - & gt; Money); printf("\n"); {} the search ()
Int b;
Printf (" \ t query order room only enter 1 \ n "); Printf (" \ t query has living room type 2 \ n "); Printf (" \ t query not living room type 3 \ n "); Printf (" \ t return to the main menu please enter 4 \ n "); Do {
The scanf (" % d ", & amp; B); The switch (b) {
Case 1: search1 (); break; Case 2: search2 (); break; Case 3: search3 (); break; Case 4: return; }
} while (b<1 | | b> 5); }
Void search1 ()
{
Char nember [10].
Struct info home * and * a find ();
Printf (" \ t enter the room number \ n ");
The scanf (" % s ", nember);
getchar();
if(! (info=find (nember)))
Printf (" \ t didn't find \ n ");
The else display (info);
}
Void search2 ()
{struct home * info; Char a [10]="have". Info=start; While (info) {
if(! STRCMP (info - & gt; A person, a)) display (info); printf("\n"); Info=info - & gt; next; }} void search3 ()
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related