Разные результаты при схожей функциональности в С++C++

Программы на C++. Форум разработчиков
Ответить
Гость
 Разные результаты при схожей функциональности в С++

Сообщение Гость »


I have the following task:

Develop a hotel reservation system to allow customers to book rooms and control demand for hotel owners. Your program should handle the following events:
  • BOOK time hotel_name client_id room_count — Book by the client with ID client_id a certain number of rooms (room_count) at the hotel named hotel_name at the specified time (time). Time is measured in seconds from a certain moment.
  • CLIENTS hotel_name — Display the count of different clients who have booked rooms at the hotel named hotel_name in the last 24 hours. More formally, the time range of interest is described as follows: let current_time be the time of the last BOOK event. In this query, consider all events with current_time - 86400 < time ⩽ current_time, where 86400 is the number of seconds in a day. Note that the last booking should be considered, and a booking exactly 24 hours prior to it should not be included.
  • ROOMS hotel_name — Display the count of rooms booked in the last 24 hours at the hotel named hotel_name.

In my first version I came up with the following approach:

#include #include #include #include #include #include #include #include using namespace std; class HotelManagement { public: HotelManagement() : hotel_rooms(), hotel_time(){} void Book (int &time, string &hotel_name, int &client_id, int &room_count){ hotel_rooms[hotel_name].push_back(room_count); hotel_time[hotel_name].push_back(time); for (auto &pair : hotel_time){ while(hotel_time.at(pair.first).front()

Источник: https://stackoverflow.com/questions/780 ... ality-in-c
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»