C
1 #include<stdio.h> 2 3 int main(){ 4 int n = 0; 5 int num = 0; 6 //printf("请输入一个不超过1000的正整数:"); 7 scanf("%d", &num); 8 while(num != 1){ 9 if(num%2 == 0){ 10 num = num / 2; 11 n++; 12 }else{ 13 num = (3*num + 1) / 2; 14 // printf("%d ",num)]; 15 n++; 16 } 17 } 18 printf("%d ", n); 19 return 0; 20 21 }