Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. for (int i = 0; i < numCarsInInput; i++)
  2. {
  3. bool checking = true;
  4. while (checking)
  5. {
  6. if (startDir == 0)
  7. {
  8. if (!carNorth.empty())
  9. {
  10. cout << "Current direction: Northbound" << endl;
  11. for (int j = 0; j < maxCar; j++)
  12. {
  13. cout << "Car " << carNorth[0] << " is using the intersection for " << carNorth[1] << " sec(s).\n";
  14. carNorth.erase(carNorth.begin());
  15. carNorth.erase(carNorth.begin());
  16. checking = false;
  17. }
  18. }
  19. startDir++;
  20. }
  21. else if (startDir == 1)
  22. {
  23. if (!carEast.empty())
  24. {
  25. cout << "Current direction: Eastbound" << endl;
  26. for (int k = 0; k < maxCar; k++)
  27. {
  28. cout << "Car " << carEast[0] << " is using the intersection for " << carEast[1] << " sec(s).\n";
  29. carEast.erase(carEast.begin());
  30. carEast.erase(carEast.begin());
  31. checking = false;
  32. }
  33. }
  34. startDir++;
  35. }
  36. else if (startDir == 2)
  37. {
  38. if (!carSouth.empty())
  39. {
  40. cout << "Current direction: Southbound" << endl;
  41. for (int m = 0; m < maxCar; m++)
  42. {
  43. cout << "Car " << carSouth[0] << " is using the intersection for " << carSouth[1] << " sec(s).\n";
  44. carSouth.erase(carSouth.begin());
  45. carSouth.erase(carSouth.begin());
  46. checking = false;
  47. }
  48. }
  49. startDir++;
  50. }
  51. else if (startDir == 3)
  52. {
  53. if (!carWest.empty())
  54. {
  55. cout << "Current direction: Westbound" << endl;
  56. for (int k = 0; k < maxCar; k++)
  57. {
  58. cout << "Car " << carWest[0] << " is using the intersection for " << carWest[1] << " sec(s).\n";
  59. carWest.erase(carWest.begin());
  60. carWest.erase(carWest.begin());
  61. checking = false;
  62. }
  63. }
  64. startDir = 0;
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement