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 fanhqme at 2009-07-15 18:15:08 on Problem 1207
In Reply To:高手帮我看一下我哪里错了呢 Posted by:bike at 2009-07-15 17:27:41
> #include <stdio.h>
> int main(int argc, char *argv[])
> {   
>     int m,n,a,count=0,max,k,l,t;
> 	while(scanf("%d%d",&m,&n)!=EOF)
> 	{     
> 	      k=m;
> 		  l=n;	
> 	      max=0;
> 	      if(m>n)
> 	      {
> 	       t=m;
> 	       m=n;
> 	       n=t;
> 	      }
> 	      
> 	    for(a=m;a<n;a++)
> 		{   
> 		   while(a!=1)
> 		   {
> 			if(a%2==0)
> 			{
> 			a=a/2;
> 			count++;
> 			}
> 			else
> 			{
> 			a=3*a+1;
> 			count++;
> 			}
> 		   }
!!!!!!!!!!!!!!!!!!!!!你已经改变了a的值!!!!
> 		   if(count>max)
> 			max=count;
> 		   
> 		}
> 			printf("%d %d %d",k,l,max);
> 		}
> 	return 0;
> }

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