解析:  新的3*n+1问题,要求在运算的过程中不超过限制,如果超过,就中断运算。

 1 #include <stdio.h>
 2 int main()
 3 {
 4     long int a, b, term, t = 0;
 5     while(scanf("%ld%ld", &a, &b) == 2 && a + b != -2){
 6         printf("Case %ld: A = %ld, limit = %ld, number of terms = ", ++t, a, b);
 7         term = 1;
 8         while(a != 1){
 9             if(a % 2)
10                 a = 3 * a + 1;
11             else
12                 a = a >> 1;
13             term++;
14             if(a > b){
15                 term--;
16                 break;
17             }
18         }
19         printf("%ld\n", term);
20     }
21     return 0;
22 }