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.h> int calculate(int i) { if(i==1) return 1; else{ if(i%2) i=3*i +1; else i=i/2; } return (1+calculate(i)); } void main() { int inputi,inputj,i; while(cin){ cin>>inputi>>inputj; int max=0; for(i=((inputi<inputj)?inputi:inputj);i<=((inputi>inputj)?inputi:inputj);i++){//要考虑i 〉j情况 int temp=calculate(i); if(max<temp) max=temp; } cout<<inputi<<" "<<inputj<<" "<<max<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator