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 |
请教师兄:为什么总是out put exeed啊?#include<stdio.h> int cycle(int m){ int count=1; while(m!=1){ count=count+1; if(m%2==1) m=3*m+1; else m=m/2; } return count; } int main(){ int i,j,a[10000],max,k,e,d,q; scanf("%d %d",&i,&j); while(i>0&&j<=10000){ d=j-i; q=i; for(k=0;k<=d+1;k++){ a[k]=cycle(i); i=i+1; } max=a[0]; for(k=0;k<=d+1;k++){ if(max<=a[k+1]) max=a[k+1]; } printf("%d %d %d\n",q,j,max); scanf("%d %d",&i,&j); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator