题解 | #xxx定律#
xxx定律
http://www.nowcoder.com/practice/75c189249d6145cfa33cd53edae6afc8
#include <iostream> #include <cstdio> using namespace std; int main() { int n; int k=0; while(scanf("%d",&n)!=EOF) { if(n==0) { break; } while(n!=1)//先判断等不等于1//这儿挺烦的 { if(n%2==0) { n=n/2; } else { n=3*n+1; n=n/2; } ++k;//每循环一次,k++ } printf("%d\n",k); } }