Traditional Culture Encyclopedia - Hotel reservation - I would like to ask how to insert another linked list into the linked list in c. For example, the hotel is a node of the first linked list, and then each room is a node of the second linked list.
I would like to ask how to insert another linked list into the linked list in c. For example, the hotel is a node of the first linked list, and then each room is a node of the second linked list.
#include?lt;iostreamgt;
using?namespace?std;
struct?room{
int?romnum;
room?*next;
};
struct?hotel
{
char?name[50 ];
room*?pr; //Pointer to room
hotel*?ph; //Pointer to next hotel.
};
void?initHotle(hotel*?amp;hp)
{
hp-gt;ph=NULL;
hp-gt; pr=NULL;
}
void?print(hotel*?amp; hp)
{
hotel*?temp=hp-gt;ph;
if(temp==NULL)?coutlt;lt;"No hotel data";
else {
while(temp){
coutlt;lt;temp-gt;name;
temp=temp-gt;ph;
}
}
}
void?findHotelRoomInfomation(char*?hname){
Look up the linked list and find a match for hname , raise its room head pointer, and then traverse the output. I won't fill it in for easy.
Do it yourself.
}
int?main(){
hotel*?p=new?hotel();
initHotle(p) ;
print(p);
?
}
This is the idea, is it clear? Regarding the addition and deletion of linked list data, there is no need for me to add it, right? ........Draw you another logic diagram.
If you want to operate a linked list, fill it in slowly yourself......
- Previous article:Xishuangbanna tourism Introduction (Catering Accommodation)
- Next article:How far is Xingsha Qin Huang Restaurant from Bus 7o3 Station?
- Related articles
- The practice of eel noodles, how to make eel noodles delicious, eel noodles.
- How can I get to Hadapu from Zhongchuan Airport to Lanzhou Railway Station by train?
- What is the telephone number of the marketing center between Xi 'an Qujiang and Yun Song?
- Which is the best decoration company in Handan?
- Do Singaporeans value Tanabata Valentine's Day?
- Nantong 202 1 Traffic Control Time and Road Section of Senior High School Entrance Examination
- 165438+1On October 30th, Liuyang City reported three cases of pneumonia in COVID-19.
- Gold map booking hotel cashback 2 1 yuan. How to cash back? Tongcheng.com received a prompt from Gao De, and then Tongcheng.com sent a text message to inform him that the reservation was successful.
- The history of London
- What is the surrounding environment of Nanning Longguang Jiuyu City? Is life convenient?