Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
HELP啊~~~~~#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator