Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

帮我看看,出了啥问题?

Posted by ccyjwtwc at 2009-11-15 21:42:45 on Problem 1207
#include <stdio.h> 
int GetLen(int n)
{
    int k=1;
	while(n!=1)
	{
	    if(n%2)n=n*3+1;
	    else n>>=1;
	    k++;
	}
	return k;
}
main()
{
    int i,n=0,m=0,max=0,t,p,q;
	while(scanf("%d%d",&n,&m)!=EOF)
	{
	
		p=n,q=m;
		if(n>m)
		{
			n=n^m;
			m=n^m;
			n=n^m;
		}
		for(i=n;i<=m;i++)
		{
			t=GetLen(i);
			if(t>max) max=t;
		}
		if(m<=n)	printf("%d %d %d\n",q,p,max);
		else printf("%d %d %d\n",p,q,max);
	
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator