ADVERTISEMENT

One of the works done by our Robotics and Machine Learning division,
SELF-LEVELING QUADCOPTER
Arduino based Quadcopter.
Self-leveling is acheived by the aligning the quadcopter using the readings from the gryo as well as the accelerometer.
A four channel RC transmitter is used to control the movement of the quadcopter when in flight. Kindly subscribe to our YouTube Channel and stay tuned.

Tuesday 26 April 2016

CSE1002:BONUS:GUEST

GUEST
Jegan organizes a family function and invite some of his friends. Many of his friends come prior to the function. Jegan has arranged for their accommodation in a hotel. The rooms are booked as the guest arrive, so the room numbers are not continous and not in any order. Jegan has the room number of the friend who had arrived first. And he has requested his friends to have a room number of the person who arrives next to him. That is the friend who arrived third will have room number of the friend who arrived fourth. The last guest will not have any room number. Given the details of each guest such as name, his room number and room number of the guest who arrived next, and room number of that Jegan has, design an algorithm and write a C++ code to print the names and room numbers to serve a coffee.
Hint: Map in STL can be used for representing the input, room number of the guest may be the key and other two details may be stored as value by representing them as a user defined data type.

UML:


CODE:
void guest::get()
 {
cin>>room_No>>name>>friend_Room_No;
}
 void hotel::get()
 {
cin>>num_Of_Guest;
 guest t;
 for (int i=0;i<num_Of_Guest;i++)
 {
t.get();
 stay_Det[t.room_No]=t;
 }
 cin>>first_Room_No;
 }
 void hotel::serve_Coffee()
 {
int i=first_Room_No;
 while (i!=-1)
 {cout<<stay_Det[i].name<<" "<<i<<endl;
 i=stay_Det[i].friend_Room_No;
 }
}


1 comment: