Code: Select all
#include <iostream>
using namespace std;
int main ()
{
int i, j, maxLength = 0, temp, count, swap;
while(cin >> i >> j)
{
int min = i;
int max = j;
if(j < i)
{
min = j;
max = i;
}
for (int k = min+1; k < max; k++)
{
temp = k;
count = 1;
while(temp != 1)
{
if(temp%2==0)
temp /= 2;
else
temp = temp*3+1;
count++;
}
if (count > maxLength)
{
maxLength = count;
}
}
cout << i << " " << j << " " << maxLength << endl;
}
return 0;
}