I can't get this code to compile in Microsoft Visual Studio 2013(it compiled in code blocks).
I only need to know where the error is.
Please help ![Frown](https://cboard.cprogramming.com/images/smilies/frown.png)
Code:
#include"stdafx.h"
#include<iostream>
using namespace std;
const long long limit = 1000001;
long long cache[limit] = { 0 };
inline long long next(long long n)
{
if (n % 2 == 0)
return n / 2;
else
return 3 * n + 1;
}
inline long long cycleLength(long long n)
{
if (n == 1) //base case
return 1;
// check if we've already cached the
// cycle length of the current number
if (n < limit && cache[n] != 0)
return cache[n];
long long length = 1 + cycleLength(next(n));
cache[n] = length;
return length;
}
int main()
{
int i, j, a, b;
long long temp;
while (cin >> i >> j)
{
long long maxLength = 0;
if (i <= j)
a = i, b = j;
else
a = j, b = i;
for (int itr = a; itr <= b; ++itr)
{
temp = cycleLength(itr);
if (maxLength < temp)
maxLength = temp;
}
cout << i << ' ' << j << ' ' << maxLength << endl;
}
}