[Login|Register]
New post

Show post

Search forum

Read topic
Why Runtime Error? 2013-05-23 13:08:28 qyq79
#include<stdio.h>

long cycle(long n)
{
    long i=1;

    while(n!=1){
        if(n%2==0){
            n=n/2;
            i++;
        }
        else{
        n=n*3+1;
        i++;
        }
    }
    return i;
}

int main()
{
    long i,j,s,max,temp;

    while((scanf("%ld %ld",&i,&j))!=EOF){
        printf("%ld %ld ",i,j);
        if(i>j){
            temp=i;
            i=j;
            j=temp;
        }
        for(max=0;i<=j;i++){
            s=cycle(i);
            if(s>max) max=s;
        }
        printf("%ld\n",max);
    }
}
Re:Why Runtime Error? 2013-11-07 20:57:03 qq510975267
return 0
Re:Why Runtime Error? 2017-01-14 16:53:04 201619822
不用 while((scanf("%ld %ld",&i,&j))!=EOF),直接用scanf就行了!
Reply
Title
Message
(64K)
University of Science and Technology of China
Online Judge for ACM/ICPC
Processed in 2.0ms with 1 query(s).