标签:
还是觉得代码放这靠谱,会定期的看看和优化代码
#include <stdio.h> #include <stdlib.h> int main() { int n; int count=0; scanf("%d",&n); if(n<=0 || n>1000)exit(0); else { while(n!=1) { if(n%2==0) { n=n/2; count++; } else { n=(3*n+1)/2; count++; } } } printf("%d\n",count); return 0; }
【PAT_Basic日记】1001. 害死人不偿命的(3n+1)猜想
标签:
原文地址:http://www.cnblogs.com/panhao/p/4247897.html