Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <string>
- #include <unistd.h>
- using namespace std;
- #define MAX 10
- int itemCount = 0;
- int front = 0;
- int rear = -1;
- string itemArray[10];
- bool isEmpty()
- {
- return itemCount == 0;
- }
- bool isFull()
- {
- return itemCount == MAX;
- }
- int size()
- {
- return itemCount;
- }
- void insert(string &personName)
- {
- if (!isFull())
- {
- if (rear == MAX - 1)
- {
- rear = -1;
- }
- //cout << "insertName = " << personName << endl;
- itemArray[++rear] = personName;
- itemCount++;
- }
- }
- string removeData()
- {
- sleep(2);
- string personName = itemArray[front++];
- if (front == MAX)
- {
- front = 0;
- }
- itemCount--;
- return personName;
- }
- int main()
- {
- int round = 3;
- for (int i = 1; i <= round; i++)
- {
- cout << "Please Enter the name of the 10 people for round " << i << endl;
- string name;
- for (int i = 0; i < 10; i++)
- {
- cin >> name;
- insert(name);
- }
- cout<< "Queue Full! Wait for the next round...\n";
- while (!isEmpty())
- {
- string showName = removeData();
- cout << showName << " is leaving...\n\n";
- }
- }
- cout << "Bank is closed for the day.\nCome again tomorrow!\nWear mask and stay safe!\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement