### Help With Scheduling Program

Hello all. I'm trying to make a program that--using the provided date--will create the optimum schedule to see 3 different movies.

The data provided will be:

an array of the runtimes
a 2d array of the showtimes

The code I have should generate every possible schedule and see which has the shortest wait time but for some reason I'm getting an error and I can't figure it out.

Here's the code:

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051`` `````` for (int l = 0; l < numMovies; l++) { for (int m = 0; m < numShowTimes[l]; m++) { currentTime = showTimes[l][m]+runTimes[l]; for (int n = 0; n < numMovies; n++) { if (l != n) { for (int o = 0; o < numShowTimes[n]; o++) { if (showTimes[n][o] > currentTime) { waitTime = showTimes[n][o] - currentTime; currentTime = showTimes[n][o]+runTimes[n]; for (int p = 0; p < numMovies; p++) { if (p != l && p !=n) { for (int q = 0; q < numShowTimes[p]; q++) { if (showTimes[p][q] > currentTime) { waitTime += showTimes[p][q]-currentTime; if (waitTime < waitTimeBest) { waitTimeBest = waitTime; var1 = l; var2 = m; var3 = n; var4 = o; var5 = p; var6 = q; } } } } } } } } } } waitTime = 0; } cout << "The best order in which to watch the movies is: " << movieTitles[var1] << " first at " << showTimes[var2] << " then " << movieTitles[var3] << " second at " << showTimes[var4] << " then " << movieTitles[var5] << " last at " << showTimes[var6];``````

I'm using xcode as my compiler and I'm getting an error that says "Thread 1: EXC_BAD_ACCESS" on bool __is_long() const _NOEXCEPT

Any insight into this error would be much appreciated.

Thank you.
Topic archived. No new replies allowed.