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 |
真心不会了,到底应该怎样结束输入,为什么我怎么改都是wa求指点,求改正啊 #include<iostream> int algrithm(int n){ int count=1; while(n!=1){ if(n%2==0) n=n/2; else n=3*n+1; count++; } return count; } int main(){ int i,j; while(scanf("%d%d",&i,&j)!=EOF){ if(j<i){ int temp=i; i=j; j=temp; } int max=0; for(int kk=i;kk<=j;kk++){ int anwser=algrithm(kk); if(max<anwser) max=anwser; } printf("%d %d %d\n",i,j,max); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator