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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

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.