Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- #include <cstring>
- #include <cstdlib>
- #include <string>
- #include <vector>
- using namespace std;
- class Hotel
- {
- int m;
- int c = -1;
- bool occupied[16];
- public:
- Hotel(){
- for(int i = 0; i < 16; i++)
- occupied[i] = false;
- };
- bool is_occupied(int p)
- {
- if(occupied[p-1] == true)
- return false;
- else
- return true;
- }
- void free_room(int p)
- {
- occupied[p] = false;
- }
- int count_free()
- {
- int count = 0;
- for(int i = 0; i < 16; i++){
- if(occupied[i] == false) count++;
- }
- return count;
- }
- int find_room()
- {
- for(int i = 0; i < 16; i++)
- {
- if(occupied[i]==false){
- occupied[i]=true;
- return i;
- }
- }
- return c;
- }
- };
- int main() {
- int n, l;
- string str;
- cin >> n;
- Hotel a;
- for(int i = 0; i < n; i++){
- cin >> str;
- if(str=="RESERVE") cout << a.find_room() << endl;
- else if(str=="FREE"){
- cin >> l;
- a.free_room(l);
- }
- else if(str=="STATUS") cout << a.count_free() << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement