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

HELP啊~~~~~

Posted by xiaobaisha at 2005-01-08 01:35:35 on Problem 1207
#include<stdio.h>
#include<math.h>
#include<malloc.h>
void main(){
	int i,j,n,k,t=0,max,p;
	int length[10000];
	while(scanf("%d %d",&i,&j)!=0){
		
		for(n=i;n<=j;n++){
			t=1;
			k=n;
			while(k!=1){
				if(k%2==1) k=3*k+1;
				else k=k/2;
				t++;
			}
			length[n-i]=t;
		}
		max=length[0];
		for(p=0;p<j-i+1;p++){
			if(length[p]>max)  
				max=length[p];
		}
		printf("%d  %d  %d\n",i,j,max);
     }
	
}
	
ps:为什么while(scanf("%d %d",&i,&j)!=0)或while(scanf("%d %d",&i,&j)==2就可以,
while(scanf("%d %d",&i,&j)==1就不可以呢?
谢谢!!~~~

					








			

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