主题:这道题错在什么地方?
http://acm.pku.edu.cn/JudgeOnline/problem?id=1207
#include<iostream.h>
#include<stdio.h>
const unsigned long N=10000;
unsigned long num(long x)
{
if(x>1)
{
if(x%2)
x=3*x+1;
else
x=x/2;
}
return x;
}
int main()
{
unsigned long x,y,m=0,a[N],i,j;
while((scanf("%d %d",&x,&y))!=EOF)
{
m=0;
for(i=x;i<=y;i++)
a[i]=i;
for(i=x;i<=y;i++)
{
while(a[i]>1)
{
m++;
for(j=x;j<=y;j++)
a[j]=num(a[j]);
}
}
cout<<x<<" "<<y<<" "<<m+1<<endl;
}
return 0;
}
#include<iostream.h>
#include<stdio.h>
const unsigned long N=10000;
unsigned long num(long x)
{
if(x>1)
{
if(x%2)
x=3*x+1;
else
x=x/2;
}
return x;
}
int main()
{
unsigned long x,y,m=0,a[N],i,j;
while((scanf("%d %d",&x,&y))!=EOF)
{
m=0;
for(i=x;i<=y;i++)
a[i]=i;
for(i=x;i<=y;i++)
{
while(a[i]>1)
{
m++;
for(j=x;j<=y;j++)
a[j]=num(a[j]);
}
}
cout<<x<<" "<<y<<" "<<m+1<<endl;
}
return 0;
}