很水的题了,就是模仿他的运算规则,对范围里每一个数进行循环,然后用一个max变量保存最大值 1207 1#include <stdio.h> 2 3int main() 4{ 5 int end,beg,length,max=0; 6 while(scanf("%d%d",&beg,&end)!=EOF) 7 { 8 max=0; 9 for(int i=beg;i<=end;i++)10 {11 int cur=i;12 length=1;13 while(cur!=1) 14 {15 if(cur%2!=0) cur=3*cur+1;16 else cur=cur/2;17 length++;18 }19 if(length>max) max=length;20 }21 printf("%d %d %d\n",beg,end,max);22 }23 return 0;24} 转载于:https://www.cnblogs.com/SoYoung/archive/2009/07/13/1522568.html