Read topic
#include<iostream>
using namespace std;
int main()
{
int i,j;
cin>>i>>j;
cout<<i<<" "<<j<<ends;
int temp=i;
int Array[10000];
int a=0;
while(temp<=j)
{
int count=1;
while(temp!=1)
{
if(temp%2==0)
temp/=2;
else
temp=3*temp+1;
count++;
}
Array[a]=count;
temp=++i;
a++;
}
int max=Array[0];
for(int n=1;n<a;n++)
{
if(max<Array[n])
max=Array[n];
else continue;
}
cout<<max<<endl;
return 0;
}
this is my answer,why it is wrong?
Re:why it is wrong
2013-05-08 14:37:13 yudan
The input are SEVERAL pairs of numbers,but your code has no cycle for this.
Reply
|