Home > Back-end >  Bosses, I am a freshman vegetables chicken, recent job completion tight, wrote a code, but don'
Bosses, I am a freshman vegetables chicken, recent job completion tight, wrote a code, but don'

Time:10-21

#include
#include
#include
#include
# define number definition M/100/room//
//function definition//
Void Stay ();//entry at function//*
Void Information ();//information query function//*
Void Browse ();//browse information function//*
Void the Save (int);//information preservation function//*
Void the read (int);//read information function//*
Void Checkout ();////check out room function
Void the Modify ();////information modify function
Void the Current ();//the current cost//*
Int judge_year (int x);
//structure definition//
Struct time
{
Int year;
Int mon;
Int the date;
Int hour;
};//structure//
Struct room
{
Char name [20].
Char ID [18];
Int flag;//0 - empty; 1 - hourly rate; 2 - charging per day//
Int prepaid;
Time t [2];//0 - check-in time; 1 - the current time//
} room [M];////room number
Char c1 [50]={0};//single room//
Char c2 [50]={0}; A double room////
//main function//
Int main ()
{
Color of 3 e system (" ");
int n;
Printf (" welcome to use \ n ");
Do {
Printf (" \ \ \ t \ \ t t t t t \ \ t \ [1] entry information t t \ \ t \ n ");
Printf (" \ \ \ t \ \ t t t t [2] information browsing \ t \ \ t t t \ \ t \ n ");
Printf (" \ \ \ t \ \ t t t t [3] information query \ t \ \ t t t \ \ t \ n ");
Printf (" \ \ \ t \ \ t t t t [4] information modify \ t \ \ t t t \ \ t \ n ");
Printf (" \ \ \ t \ \ t t t t [5] the current cost \ t \ \ t t t \ \ t \ n ");
Printf (" \ \ \ t \ \ t t t t t \ \ t [6] check out room \ t t \ \ t \ n ");
Printf (" \ \ \ t \ \ t t t t t \ \ t \ [0] to exit the program t t \ \ t \ n ");
Printf (" please enter what you want to do \ n ");
The scanf (" % d ", & amp; N);
If (n<0 | | n> 7)
{
Printf (" input operation code error, please input again \ n ");
The scanf (" % d ", & amp; N);
}
The switch (n)
{
Case: 0 exit (0);
Case 1: Stay (); break;
Case 2: Browse (); break;
Case 3: Information (); break;
Case 4: the Modify (); break;
Case 5: Current (); break;
Case 6: Checkout (); break;
}
} while (n!=0);
}
Void Stay ()////entry into function
{
system("cls");
Color of 3 e system (" ");
Printf (" tip: the hotel room number 1-50 for a single room; 51-100 for a double room with \ n input time format: 2010-2-23 ");
Int I, j, l, k;
Int TAB [2] [12]={
31,28,31,30,31,30,31,31,30,31,30,31 {},
{31,29,31,30,31,30,31,31,30,31,30,31}
};
Printf (" please input you will check in room number: ");
The scanf (" % d ", & amp; I);
Do {
Printf (" you enter the room number is wrong, please input again: ");
The scanf (" % d ", & amp; I);
} while (i<0 | | i> 100);
Read (I);
While (room [I - 1]. The flag!=0)
{
Printf (" I'm sorry, the room for guest check in, please enter a different room number: ");
The scanf (" % d ", & amp; I);
Read (I);
}
Printf (" please input your name: ");
The scanf (" % s ", & amp; Room [I - 1]. Name);
J=strlen (room [I - 1]. Name);
While (j<0 | | j> 20)
{
Printf (" input wrong your name, please enter again: ");
The scanf (" % s ", & amp; Room [I - 1]. Name);
J=strlen (room [I - 1]. Name);
}
Printf (" please enter your id number: ");
The scanf (" % s ", & amp; Room [I - 1]. ID);
J=strlen (room [I - 1]. ID);
While (j!=18)
{
Printf (" you enter the identification number is wrong, please input again: ");
The scanf (" % s ", room [I - 1]. ID);
J=strlen (room [I - 1]. ID);
}
If (i<=50)
{
Printf (" you choose is a single room, the room's billing way is: 148 yuan/day; 8 yuan/hour ");
Printf (" please select a billing method: [1] by the hour. [2] by day fee ");
}
The else
{
Printf (" you selected is a double room, the room pricing way is: 188 yuan/day; 10 yuan/hour ");
Printf (" please select a billing method: [1] by the hour. [2] by day fee ");
}
The scanf (" % d ", & amp; Room [I - 1]. The flag);
While (room [I - 1]. Flag<=0 | | room [I - 1]. Flag> 2)
{
Printf (" you enter billing way is wrong, please input again: ");
The scanf (" % d ", room [I - 1]. The flag);
}
Printf (" input your check-in time: ");
The scanf (" % d % d % d - % d ", & amp; Room [I - 1] t [0]. Year, & amp; Room [I - 1] t [0]. Mon, & amp; Room [I - 1] t [0]. Date, & amp; Room [I - 1] t [0]. Hour);
L=judge_year (room [I - 1] t [0]. Year);
While ((room [I - 1] t [0]. Year<=2020) | |
(room [I - 1]. T [0]. Mon<=0 | | room [I - 1] t [0]. Mon> 12)
| | (room [I - 1] t [0]. Date<=0 | | room [I - 1] t [0]. Date> TAB [l] [room [I - 1] t [0]. Mon - 1]) | |
(room [I - 1]. T [0]. Hour<0 | | room [I - 1] t [0]. Hour>=24))
{
Printf (" you enter the check-in time is wrong, please input again: ");
The scanf (" % d % d % d - % d ", & amp; Room [I - 1] t [0]. Year, & amp; Room [I - 1] t [0]. Mon, & amp; Room [I - 1] t [0]. Date, & amp; Room [I - 1] t [0]. Hour);
L=judge_year (room [I - 1] t [0]. Year);
}
Printf (" please enter your deposit amount (deposit as an integer) ");
The scanf (" % d ", & amp; Room [I - 1]. Prepaid);
While (room [I - 1]. Prepaid<=0)
{
Printf (" your deposit amount is wrong, please input again: ");
The scanf (" % d ", & amp; Room [I - 1]. Prepaid);
}
Printf (" please check your information is entered correctly!" );
Printf (" input 1 shows that the information is correct, otherwise the input 2 ");
The scanf (" % d ", & amp; K);
If (k==1)
{
Printf (" you have to check in, I wish you a happy stay!" );
Save (I);
}
The else
{
Stay ();
}
}
Void the Current ()////currently cost function
{
system("cls");
Color of 3 e system (" ");
Int I, j, k;
Int TAB [2] [12]={
31,28,31,30,31,30,31,31,30,31,30,31 {},
{31,29,31,30,31,30,31,31,30,31,30,31}
};
Int day=0;
Int hr=0;
Int total_hour;
Int total_day;
Long int price;
Printf (" please enter your room number: ");
The scanf (" % d ", & amp; I);
While (i<0 | | i> 100)
{
Printf (" you enter the room number is wrong, please input again: ");
The scanf (" % d ", & amp; I);
}
Read (I);
While (room [I - 1]. Flag==0)
{
Printf (" temporarily deserted the room, please re-enter the room number: ");
The scanf (" % d ", & amp; I);
Read (I);
}
Printf (" please input the current time: \ n input time format: 2010-2-23 ");
Shuru:
The scanf (" % d % d % d - % d ", & amp; Room [I - 1] t [1]. Year, & amp; Room [I - 1] t [1]. Mon, & amp; Room [I - 1]. T [1], the date, & amp; Room [I - 1]. T [1]. The hour);
J=judge_year (room [I - 1] t [1]. The year);
While ((room [I - 1] t [1]. The year<=2020) | |
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull