Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (int i = 0; i < numCarsInInput; i++)
- {
- bool checking = true;
- while (checking)
- {
- if (startDir == 0)
- {
- if (!carNorth.empty())
- {
- cout << "Current direction: Northbound" << endl;
- for (int j = 0; j < maxCar; j++)
- {
- cout << "Car " << carNorth[0] << " is using the intersection for " << carNorth[1] << " sec(s).\n";
- carNorth.erase(carNorth.begin());
- carNorth.erase(carNorth.begin());
- checking = false;
- }
- }
- startDir++;
- }
- else if (startDir == 1)
- {
- if (!carEast.empty())
- {
- cout << "Current direction: Eastbound" << endl;
- for (int k = 0; k < maxCar; k++)
- {
- cout << "Car " << carEast[0] << " is using the intersection for " << carEast[1] << " sec(s).\n";
- carEast.erase(carEast.begin());
- carEast.erase(carEast.begin());
- checking = false;
- }
- }
- startDir++;
- }
- else if (startDir == 2)
- {
- if (!carSouth.empty())
- {
- cout << "Current direction: Southbound" << endl;
- for (int m = 0; m < maxCar; m++)
- {
- cout << "Car " << carSouth[0] << " is using the intersection for " << carSouth[1] << " sec(s).\n";
- carSouth.erase(carSouth.begin());
- carSouth.erase(carSouth.begin());
- checking = false;
- }
- }
- startDir++;
- }
- else if (startDir == 3)
- {
- if (!carWest.empty())
- {
- cout << "Current direction: Westbound" << endl;
- for (int k = 0; k < maxCar; k++)
- {
- cout << "Car " << carWest[0] << " is using the intersection for " << carWest[1] << " sec(s).\n";
- carWest.erase(carWest.begin());
- carWest.erase(carWest.begin());
- checking = false;
- }
- }
- startDir = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement