水题 只是卡在细节上 没有说 输入一定是 A小于B 呵呵 实现函数 没有太多的可以说道的地方。。。
 # include <stdio.h>
# include <stdio.h>
 int fun(long  a ,int len)
int fun(long  a ,int len)


 {
{
 if (a ==1)
    if (a ==1)
 return len;
        return len;
 else if (a %2 ==0)
    else if (a %2 ==0)
 return fun(a/2,len+1);
        return fun(a/2,len+1);
 else  return fun(3*a+1,len +1);
    else  return fun(3*a+1,len +1);
 }
}
 int main()
int main()


 {
{
 unsigned long  a,b;
    unsigned long  a,b;
 unsigned long i,max,temp;
    unsigned long i,max,temp;

 while (scanf("%ld%ld",&a,&b)!=EOF)
    while (scanf("%ld%ld",&a,&b)!=EOF)

 
     {
{
 printf("%ld %ld ",a,b);
        printf("%ld %ld ",a,b);

 if(a>b)
        if(a>b)  {i = a;a=b;b=i;}
{i = a;a=b;b=i;}
 for (max = 0,i = a; i <= b; i ++)
        for (max = 0,i = a; i <= b; i ++)

 
         {
{
 temp = fun(i,1);
            temp = fun(i,1);
 if (max < temp)
            if (max < temp)
 max = temp;
                max = temp;
 }
        }
 printf("%ld\n",max);
        printf("%ld\n",max);
 }
    }
 return 0;
    return 0;
 }
}

 
 
 
	posted on 2010-04-11 10:41 
付翔 阅读(237) 
评论(0)  编辑 收藏 引用  所属分类: 
ACM 数据结构