[Login|Register]
New post

Show post

Search forum

Read post
求助这段哪儿有问题吗,实在是找不到问题了 [ Topic ] 2013-03-02 19:58:13 Himdeng
#include<stdio.h>
int main()
{
    int a,b;
    int tempa,tempb;
    int temp,k;
    int i=1,j=1;
    do
    {
        scanf("%d %d",&a,&b);
        if(a>b)
        {
            tempa=b;
            tempb=a;
        }
        else
        {
            tempa=a;
            tempb=b;
        }
        for(k=tempa;k<=tempb;k++)
        {
            temp=k;
            while(temp!=1)
            {
                if(temp%2==0)
                {
                    temp=temp/2;
                    j++;
                }
                else
                {
                    temp=temp*3+1;
                    j++;
                }
                if(j>i) i=j;
            }
            j=1;
        }
        printf("%d %d %d\n",a,b,i);
        i=1;
    }while(getchar()!=EOF);
    return 0;
}
Reply
Title
Message
(64K)
University of Science and Technology of China
Online Judge for ACM/ICPC
Processed in 1.7ms with 2 query(s).